Articles & Books

Quick Q: Are class member initializers evaluated at compile time? -- StackOverflow

Quick A: Maybe.

Recently on SO:

Does in class member initialization takes place at compile time or run-time?

In C++11 a new feature was introduced where the programmer can initialize class member variables inside class's definition, see code below:

struct foo
{
  int size = 3;
  int id   = 1;
  int type = 2;
  unsigned char data[3] = {'1', '2', '3'};
};

Is this initialization takes place during compile time or this feature is just syntactic sugar and member variables are initialized in the default constructor?

Nugget: Context-sensitive keywords -- Tony DaSilva

Recently on Bulldozer00:

Context Sensitive Keywords

by Tony DaSilva

From the article:

With the seriousness of keyword introduction in mind, one might wonder why the override and final keywords were added to C++11. Surely, they’re so common that millions of lines of C/C++ legacy code will get broken. D’oh!

But wait! To severely limit code-breakage, the override and final keywords are defined to be context sensitive...

Range Comprehensions -- Eric Niebler

Do you "comprehend" ranges? From a key participant in some of the latest discussion about ranges for C++:

Range Comprehensions

by Eric Niebler

From the article:

I’ve been busy since I last wrote about ranges. I have a lot of news to share, but in this post, I’m going to narrowly focus on a recent development that has me very excited. It’s a new feature that I’m calling range comprehensions, and they promise to greatly simplify the business of creating custom ranges...

noexcept: what for? -- Andrzej KrzemieĊ„ski

From the desk of Andrzej:

noexcept -- what for?

by Andrzej Krzemieński

From the article:

In this post I would like to share my observation on where using noexcept really adds value. It is less often than what one might expect, and it does not have that much to do with throwing or not throwing exceptions. The conclusion surprises me a bit, and I hesitate to present it because it is counter to the advice I hear from people I consider authorities on the subject...

Async-Await in C++ -- Paolo Severini

severini-await.PNGParis, April 2014: Paolo Severini explores the Async-Await pattern and the related proposal for C++17, showing also an example by using Visual Studio 2013 November CTP.

Async-Await in C++

by Paolo Severini

From the article:

... what about native [C++] programming? Is there anything like async/await that we can use with our futures? We can find the answer in N3858, another proposal made by Gustafsson et al. for C++17.

This time the changes proposed are to the language itself and not just to the library. The idea is to introduce the equivalent of C# async methods in the form of resumable functions. They can be thought as the basis to add to C++ the support for real co-routines, and are not strictly related to the <future> library, even though they have being defined especially to improve the usability of futures and promises...

Writing a simple bar graph widget in Qt

Recently I had to implement a simple version of a bar graph widget in Qt:

Writing a bar graph widget in Qt

by Jens Weller

From the Article:

Today I had a little fun with Qt and wrote a widget for displaying a bar graph. I have two different situations where I need the bar graph in my back end: displaying the votes a single talk got, and displaying one big bar graph of all the talks.

Preferring STL algorithms from algorithm and numeric -- makramkd

(Related note: If you haven't yet watched and grokked Sean Parent's wonderful C++ Seasoning talk from last fall's GoingNative conference, do yourself a favor and watch it. You will find it eye-opening. If you have already watched it, you might still find it worth a re-watch to fully absorb.)

Here's a nice case study of why not to roll your own algorithms, when C++ comes with a treasure chest full of pre-written, pre-debugged, and pre-optimized (in a good way) standard algorithms in the box:

Preferring STL algorithms from algorithm and numeric

by makramkd

From the article:

This post isn’t meant to be a documentation of the algorithm and numeric headers: you can find those readily at cppreference. In this post I’m going to try to convince people that write very similar algorithms to those in the standard library to not use these algorithms in production code, and to prefer ones from the STL.

Let’s get the show on the road. I’m going to start with the most simple one, because I just want to get my point across.

Understanding the New Set and Map Containers in the C++11 Standard Library -- S Clamage and D Gove

On the Oracle Tech Network, a nice reminder of the still-"new"-to-some hash-based containers, co-authored by the chair of the U.S. C++ standards committee:

Understanding the New Set and Map Containers in the C++11 Standard Library

by Steve Clamage and Darryl Gove

From the article:

One of the areas in the new C++ standard that has seen the most enhancement is the Standard Library. The functionality that is most likely to be immediately useful to developers is the additions to the container classes. This article describes the new set and map containers.