C++ is fun

We all know C++ is a powerful yet complex programming language. But it can also be fun. For instance, you can use emojis and other Unicode characters in the source code. Of course, nobody sane would use emojis for identifiers. But it’s possible and you can have a little fun if have some spare time.

Identifiers are sequences of digits, underscores, lowercase and upper case Latin letters, and most Unicode characters. Identifiers are not allowed to begin with a digit, they must begin with an underscore, a Latin letter, or a non-digit Unicode character. For more information about the Unicode characters in identifiers see this.

So here is a little example of a C++ program that uses emojis. Can you figure out what it does?

Enabling TLS 1.2 in your .NET framework applications

A functionality of one of the products I’m working on suddenly stopped working without any code changes on our side. Our application connects to a web service to get some data and that no longer worked, our customers getting the following error in their logs “The underlying connection was closed: An unexpected error occurred on a send.” The first thing to do was checking whether the web service was still up and running as expected. The requests made with SoapUI or Postman were all successful, so it was actually something in our application that was actually wrong. So I decided to use Fiddler to look at how our requests look and what do we get back.

Three productivity features in the Visual C++ 2017 debugger

Visual Studio 2017 has had a larger number of updates throughout its lifetime. At the time of writing this article, there have been ten major updates and countless minor ones. You can check the release notes history for details. Part of the changes was in the debugger. In this article, I will mention three features…

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.

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.