Yearly Archives: 2017

Expressive C++ Template Metaprogramming

Published June 2, 2017 - 3 Comments
Expressive template metaprogramming tmp

There is a part of C++ developers that appreciate template metaprogramming. And there are all the other C++ developers. While I consider myself falling rather in the camp of the aficionados, I’ve met a lot more people that don’t have a strong interest for it, or that even find it downright disgusting, than TMP enthusiasts. Which camp do you […]

Making Strong Types Hashable

Published May 30, 2017 - 5 Comments

Strong types are types that are built over primitive types, and add meaning to them. My purpose today is two-fold: showing you how to write an STL-compliant hash function for custom types so that they can be used in unordered containers such as std::unordered_map, making a hash function available for strong types. For more about the motivation […]

Strong Units Conversions

Published May 26, 2017 - 0 Comments

Strong types are a way to add a meaning to objects by giving them a meaningful name, by using types. This lets the compiler, human beings, and developers understand better the intent of a piece of code. We’ve been exploring strong types on Fluent C++. I focus here on how to define strong types conversions. If you want to catch […]

Strong types: inheriting the underlying type’s functionalities

Published May 23, 2017 - 5 Comments

This post is part of the series on strong types: Strongly typed constructors Strong types for strong interfaces Passing strong types by reference Strong lambdas: strong typing over generic types Good news: strong types are (mostly) free in C++ Inheriting functionalities from the underlying type Making strong types hashable Converting strong units to one another Metaclasses, the […]

The Curiously Recurring Template Pattern (CRTP)

Published May 12, 2017 - 11 Comments
CRTP definition curiously recurring recursive template pattern

The Curiously Recurring Template Pattern (CRTP) is a C++ idiom whose name was coined by James Coplien in 1995, in early C++ template code. The “C” in CRTP made it travel the years in the C++ community by being this: a Curiosity. We often find definitions of what CRTP is, and it is indeed an […]

Good news: strong types are (mostly) free in C++

Published May 5, 2017 - 3 Comments

Strong types are a simple and efficient tool for improving code expressiveness, by letting you express your intentions better to both the compiler and to your fellow human companions. This post is part of the series about strong types, that keeps growing because it is such a rich topic: Strongly typed constructors Strong types for strong […]

To comment or not to comment? // that is the question

Published May 2, 2017 - 4 Comments

Comments are one of these places where religion meets technology. On one side there are the firm believers that good code is commented code, and on the other side stand the devout to the scarcest commenting chapel. We can’t discuss expressive code and not talk about comments at some point. Is code expressiveness an alternative to comments, or are the […]

1 5 6 7 8 9 11