Tag Archives: c++17

Reflection for aggregates

An aggregate is an array or a class with no user-declared or inherited constructors, no private or protected direct non-static data members, no virtual functions, and no virtual, private, or protected base classes. Aggregates can be initialized in aggregate initialization, … Continue reading

Posted in programming | Tagged , , | 1 Comment

Short-circuiting in meta-functions

Short-circuiting in logical operations is a very useful and an often used feature: Should cond_a() evaluate to false, cond_b() is guaranteed not to be evaluated. This is useful for two reasons. One is performance: if cond_b() is an expensive operation … Continue reading

Posted in programming | Tagged , , , | 4 Comments

Deducing your intentions

The language feature in C++17 known as class template argument deduction was intended to supersede factory functions like make_pair, make_tuple, make_optional, as described in p0091r2. This goal has not been fully achieved and we may still need to stick to … Continue reading

Posted in programming | Tagged , , | 14 Comments

Rvalues redefined

In this post we will explore what I consider the most significant language change in C++17. I call it the most significant because it changes the way you design your resource-managing types and how you think about initialization. It is … Continue reading

Posted in programming | Tagged , | 37 Comments

Help the compiler warn you

Compiler warnings are a very useful tool for detecting bugs in your program. Because you can enable them selectively, and because you can choose to turn them into hard errors on your compiler, you can in fact build a dialect, … Continue reading

Posted in programming | Tagged , , , | 8 Comments

Your own type predicate

In this post we will see how to define a type trait or a type predicate or a meta-function that would allow us to check at compile time whether a type exposes an interface that we need. That is, we … Continue reading

Posted in programming | Tagged , , , , , , | 19 Comments

Compile-time string concatenation

We will start with a bug, taken from real life. It spans across three files: Question: what happens when this program is executed?

Posted in programming | Tagged , , , , , | 35 Comments

Clever overloading

This post is intended to be a light introduction to certain C++ guru tricks. I want to introduce a couple of concepts that typically put normal people off. If you are an expert you will probably not learn anything new, … Continue reading

Posted in programming | Tagged , , , , , | 26 Comments