Putting the fun in C++

The post-Kona mailing list of the new standards papers has been recently published (you can find it here). Going through the titles I could not help smiling because some of them are really funny. So I decided to make a top 10 of the funniest paper titles.

Little-known C++: operator auto

A user-defined conversion function enables an implicit or explicit conversion between types. Such, a function has the following form (no return type and no parameters):

struct foo
{
   operator int() const {return 42;}
};

foo f;
int i = f;  // implicit conversion

Little-known C++: function-try-block

Function-try-block is a mechanism in C++ to establish an exception handler around the body of a function. The following is an example:

int foo() 
{
   throw std::runtime_error("oops...");
}

int main()
try
{
   foo();
   return 0;
}
catch (...)
{
   return -1;
}

C++ code samples before and after Ranges

The Ranges library proposal has been accepted for C++20 at the San Diego meeting of the standard committee in November last year. The library provides components for handling ranges of values aimed at simplifying our code. Unfortunately, the Ranges library is not very well documented, which makes it harder to grasp for those that want to learn it. This post is intended as an introduction based on examples of code written with and without Ranges.

Understanding equal_range

std::equal_range is a general purpose standard algorithm used to find a sub-range of values in a given sorted or at least partitioned range. In this post, I will explain how the algorithm works.

A first look at Visual Studio 2019

The first preview version of Visual Studio 2019 is available since the beginning of December 2018. I decided to take a look to see what is different from the previous Visual Studio 2017 version. In this post, I will present some of the things that are new or changed in this new version.

Advent of Code 2018

I have recently come across a website that proposes a series of programming challenges throughout December, until Christmas. It’s called Advent of Code and this is the fourth year it runs this competition. Every day, a new challenge is made available, and each challenge has two parts. You only get the second part after completing the first. It does not matter what programming language you use for solving the challenge, nor how the code looks or how fast it executes. The only thing that matters is the result.

Join the East Const revolution!

The C++ community has worked hard in the past decade and more to move the language forward, to enrich but also simplify it, and to adopt new paradigms and coding styles. Yet, a single topic, a simple matter of style is splitting the community, in a pure Swiftian manner: the use of the const qualifier that some prefer it on the left of what it modifies, as it has been the de facto standard for decades, and which is now called West const, or to the right of that it modifies, that is a style that more and more people are adopting, and which is now called East const. I don’t particularly like this terms, I would rather use left const and right const, but if this is what the community prefers to use let’s call them so for consistency.