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

Interlude

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...

25 Oct, 2013

True Story: Call Me Maybe

The call_me_maybe function takes a target as its only argument. If the target object can be called with some specific arguments, it will call it. But not immediately —it doesn't want to look desperate—; instead, it will store it somewhere until the time is right. What follows is how such a crazy function is implemented...

29 Sep, 2013

Episode Seven: One Char to Rule them All

There are 5 types of character literals in C++. Two types of character literal for the narrow-kings under the sky, two for the universal-lords in their halls of stone, one for the mortal wide doomed to die, in the land of C++ where the shadows lie.

30 Aug, 2013

Episode Six: Boollocks

In the beginning there was no bool. And C++ said "let there be bool", and there was bool...

The Boolean data type is an integral type with only two values: true and false, intended to represent the truth values of logic and Boolean algebra. With only two values, what can possibly go wrong?

31 Jul, 2013

True Story: I Will Always Find You

A customization point is a code construct that the user can leverage to specialize how a particular library action is handled. A common way of implementing this in C++ is to define a template with the default behavior, and let users specialize it for their own types —e.g., std::hash—. This is the story of Spirit X3 and how it lets you specialize customization points without ever leaving your own namespace, sort of...

← Older posts