23 Mar, 2015

Eggs.Variant - Part II (the constexpr experience)

Ruminations on the development of Eggs.Variant, a C++11/14 generic, type-safe, discriminated union. Part I explored a straightforward implementation based on untyped raw storage appropriate to hold any of the variant members. It was noted, however, that such an implementation would never be constexpr-aware. It's time to throw it away and start from scratch in order to properly support constexpr.

01 Jan, 2015


One year down the road, 2014 has gone by but not without modifications to the C++ lands. C++14 was completed, and Clang has already reached full conformance! But it's not the end of the road, while the Technical Specification (TS) documents continue to move forward, work has started on what it is intended to be C++17...

10 Sep, 2014

Episode Ten: When Size Does Matter

In the C++ lands every object has mass; for any complete type T, sizeof(T) is greater than zero. This keeps array indexing and pointer arithmetics from collapsing, but it also means that empty objects occupy space. Furthermore, when an empty object is placed in a class next to a bigger member, padding may —and in all likeliness will— be added due to alignment requirements, resulting in an empty member taking more than just one byte of storage. Certainly something has to be done about this...

30 Jun, 2014

Episode Nine: Erasing the Concrete

Templates are an extremely powerful C++ feature that enables writing generic implementations that are also highly efficient. By instantiating the implementation for each combination of template arguments used it is possible to generate code equivalent or close to that of a hand-written implementation. However, this type-awareness that opens the door to efficiency also closes the door to crossing virtual or binary interfaces, as well as preventing other everyday activities like storing things in a container. Thus, it is often necessary to collapse all this generality into a single type, effectively erasing the concrete type of the objects involved.

20 Feb, 2014

Rant: On the Templated Nature of std::chrono

There is a trending misconception about the templated nature of std::chrono. The claim comes in different forms, but it always boils down to std::chrono::duration and std::chrono::time_point being templates and thus impossible to use together with virtual functions or across a binary interface. The claim seems to be based on the assumption that using the templated features of std::chrono require templates all the way down, which is blatantly wrong...

20 Jan, 2014

True Story: Moving Past Bind

C++ provides std::bind for partial function application, which is the process of fixing a number of arguments to a function, producing another function of same or smaller arity. In the C++ lands, std::bind returns a function object which stores copies of the fixed arguments —known as bound arguments—, allowing the resulting bind expression to be called at points far from where it was created, multiple times if desired. This has important implications when the intention is to make that call just once...

01 Jan, 2014


One year down the road, 2013 has gone by but not without modifications to the C++ lands. Two major compilers have reached C++11 conformance —GCC and Clang —. Shortly after, the Committee Draft (CD) for C++14 was completed, which is now just around the corner...

← Older posts