Jonathan Boccara's blog

Lower and Upper Bound Insert Iterators

Published December 27, 2019 - 0 Comments

This is a guest post by Anton Vodostoev. Anton is a C++ developer and follower of Fluent C++. I liked the idea of creating different types of smart iterators when reading the articles “About Smart Output Iterators” by Jonathan. One of them suggested me an idea I wanted to talk about. The problem Imagine we […]

My Christmas Gift For You

Published December 24, 2019 - 0 Comments

Tonight is Christmas! Jingle bells, jingle bells, jingle all the way… I hope that you’re enjoying this special part of the year! As it is customary to offer gifts to each other at Christmas, let me offer you my gift: Untie the knot, tear the wrapping paper open, lift the lid of the box and […]

Comparing C++ Containers with Lexicographical Comparison

Published December 20, 2019 - 0 Comments

What does is mean to compare two collections of objects to determine which collection is smaller? Even if comparison is natural for some types, comparing compound types that contain them can be trickier. For example, real numbers have a natural order (1.414 is smaller than 3.14) but complex numbers don’t have an order (1 + […]

How to Increment a Dynamic Bitset with the STL

Published December 17, 2019 - 0 Comments

While working on a project involving bitsets, I had to implement a function that adds 1 to a binary number represented by a bitstet. In this article, we will compare how to implement such a function by using a for loop VS using STL algorithms. C++ has two types of bitsets. The first type are […]

How to Write a Condition With Interdependent Variables

Published December 13, 2019 - 0 Comments

Sometimes, the simplest requirements can be tricky to code in an expressive manner. For example, I recently had to code up some logic to determine if a transaction consisted in paying money or receiving money. To determine this, the transaction has two relevant parameters: the price of the transaction, that can be positive or negative. […]

Don’t Make Your Interfaces *Deceptively* Simple

Published December 10, 2019 - 0 Comments

Just because we can provide an interface doesn’t mean that we should. At least this is one of the takeaways that I got from from Howard Hinnant’s opening keynote at Meeting C++ 2019. In this impressive keynote, Howard made a presentation about <chrono> and the host of features it brings in C++20. But beyond showing us […]

My Book on Legacy Code is on Amazon

Published December 6, 2019 - 0 Comments

My first book, The Legacy Code Programmer’s Toolbox, is now available on Amazon: A lot of people asked me this. Until now, the book was only available in its electronic form on Leanpub. Now it’s available in print, on Amazon! What the book is about The Legacy Code Programmer’s Toolbox has been written with two goals […]

Inserting Values to a Map with Boost.Assign

Published December 3, 2019 - 0 Comments

Boost.Assign is a library that allows for a natural syntax to add elements to a container: std::vector<int> v; v += 1,2,3,4,5,6,7,8,9,10; We’ve seen how it works with vectors and sets, now we will focus on maps. Indeed, maps don’t work the same way. The following code, despite that it looks nice, doesn’t compile: #include <boost/assign/std/map.hpp> […]

Appending Values to a Vector with Boost.Assign

Published November 29, 2019 - 0 Comments

C++11 has simplified the syntax to initialize an STL collection with values. Before C++11 we had to write this: std::vector<int> v; v.push_back(1); v.push_back(2); v.push_back(3); v.push_back(4); v.push_back(5); v.push_back(6); v.push_back(7); v.push_back(8); v.push_back(9); v.push_back(10); Now C++11’s std::initializer_list allows to write that instead: std::vector<int> v = {1,2,3,4,5,6,7,8,9,10}; But what if v is an existing vector, to which we’d like to append […]

NEW! Get a Mini-Ebook on a C++ Topic Every Month

Published November 26, 2019 - 0 Comments

There is just too much to know to master programming in C++. I’m not talking about putting together small programs in C++. I’m talking about mastering the skills that are required to create industry-level software. When it comes to the code itself, you need to master at least the following things: the core concepts of […]