Jonathan Boccara's blog

A new post every Tuesday and Friday morning

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 […]

All about Mins and Maxes with the STL

Published April 11, 2017 - 6 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 - 0 Comments

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 […]

Filling <algorithm>s of the STL

Published March 23, 2017 - 0 Comments

This post is part of the STL learning resource. Today we focus on how to fill out a range or a container with the STL. std::fill and std::uninitialized_fill std::fill takes a range and a value, and sets all elements of the range as equal to this value.

std::fill calls operator= on each element. std::uninitialized_fill does essentially the […]

A smart iterator for inserting into a sorted container in C++

Published March 17, 2017 - 2 Comments

Smart iterators add great potential to writing expressive code with the STL in C++. And the ones that are proposed natively work particularly well with vectors and with other sequence containers such as deque, list and string. But the situation is not as good for associative containers, such as maps and sets (or their flat- non-standard counterparts). […]