Jonathan Boccara's blog

A new post every Tuesday and Friday morning

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 - 4 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). […]

Functors are not dead: the double functor trick

Published March 9, 2017 - 8 Comments

When C++11 arrived, lambdas were massively used in the places where functors used before. Lambdas are more elegant, involve less typing and can do pretty much all that functor did. Pretty much. But not quite. We covered how to make code expressive by using lambdas in a dedicated post, but there are a few use […]

Passing strong types by reference

Published March 6, 2017 - 15 Comments

On Fluent C++ we had already considered passing strong types by references, and realized that this wasn’t such a simple thing to do. To understand why, I suggest you read the problem statement in this previous post before starting this one, so that we are in line. So far the series on strong types contains […]

The Pi Day Challenge For The Most Expressive Code In C++

Published March 2, 2017 - 10 Comments

Each year, the fourteenth of March is marked by a very special event: Pi Day! It’s called this because in American notation, the 14th of March is 3/14. And during this day, the number Pi is celebrated all over the world in various ways. One notable way to celebrate it is bringing a pie to work or to university. […]