Yearly Archives: 2017

Move iterators: where the STL meets Move semantics

Published April 25, 2017 - 3 Comments
move iterators

In C++11, a host of new features were introduced in the language and the Standard Library, and some of them work in synergy. Move iterators are an example of how the STL collaborates with move semantics, to allow expressing several important concepts in a very well integrated piece of code. Well, almost. By using the native features only, we don’t get […]

How to split a string in C++

Published April 21, 2017 - 44 Comments

How to split a string in C++? That is to say, how to get a collection of substrings representing the words of a sentence, or the pieces of data contained in a CSV entry? This is a simple question, but one which has multiple answers in C++. We will see 3 solutions, each one having advantages and […]

The design of the STL

Published April 18, 2017 - 7 Comments

As a logical part of the STL learning resource, here is how the STL has been designed, and how you can design your components to make them benefit from the power of the STL. The design of the STL has been driven by the intention of separating algorithms from data structures. Algorithms include: those in the […]

Understand ranges better with the new Cartesian Product adaptor

Published April 14, 2017 - 3 Comments

A couple of days ago, the range-v3 library got a new component: the view::cartesian_product adaptor. Understanding what this component does, and the thought process that went through its creation is easy and will let you have a better grasp of the range library. (Note that you could just as well understand all the following by looking at the […]

Mins and Maxes with the STL

Published April 11, 2017 - 7 Comments

Min and max are such simple functions that there is not much to say about them… or are they? The basic algorithms min, max Functionally speaking, std::min and std::max are doing simple things indeed: they take two values, and return the smaller of the two for std::min and the bigger of the two for std::max. Here […]

Restricting an interface in C++

Published April 7, 2017 - 6 Comments

My colleague and friend Jonathan came up to me the other day with this request: “Jonathan”, he said – you won’t have too many names to remember to follow this story – “Jonathan, how would you go about restricting the methods of an interface? We’ve got a class which we use in a broader context, […]

How typed C++ is, and why it matters

Published March 31, 2017 - 1 Comment

For the third time I attended the meetup of Software Craftmanship in Paris. And like the first time and the second one, it was superb experience again. This meetup lets the participants collectively choose the topics to be discussed. There I proposed to confront, as a group, the various languages that the people in the room knew (the […]