Here’s an exercise: given a nice piece of code sitting in a file, how do you take that code and make it generic, in the style of an STL algorithm? For our example, let’s consider an algorithm that isn’t (yet) in the STL. First, the problem it solves. Imagine that you have a set (in… Continue reading Development of an Algorithm
Month: June 2017
C++17 Class Templates: Deduced or Not?
C++17 introduces class template deduction: a way for the compiler to deduce the arguments to construct a class template without our having to write a make_* function. But it’s not quite as straightforward as it seems. Imagine we have a simple type that will tell us when it’s copied or moved, just for testing. struct… Continue reading C++17 Class Templates: Deduced or Not?