Jonathan Boccara's blog

A new post every Tuesday and Friday morning

(std::)Accumulate Knowledge On STL Algorithms

Published October 17, 2017 - 0 Comments

If there’s one algorithm that lets you do all sorts of things, that must be std::accumulate. It is important to know how to use it, and also how not to use it. This post is part of the STL Learning Resource. Basic usage Numeric types The first thing to know about std::accumulate is its location: the […]

Size and Capacity of STL Containers

Published October 13, 2017 - 0 Comments

Size and capacity are concepts that look somewhat similar from afar. But mixing them up can lead to under-optimized or even plain wrong code. This article explains all about size and capacity of standard containers, and how these two concepts differ. A big thanks to  Stephan T. Lavavej, who kindly provided his feedback on the […]

Partitioning with the STL

Published October 10, 2017 - 1 Comment
partition STL

Partitioning a collection consists in reordering it so that the elements that satisfy a given predicate are moved up to the beginning, and those that don’t satisfy it are moved down after them. The first element that does not satisfy the predicate is called the partition point. This is also the end of the subrange of elements […]

How the STL inserter iterator really works

Published October 6, 2017 - 0 Comments

The inserter iterators such as std::back_inserter and std::inserter are important components in the STL that participate in letting us improve the expressiveness of our code. Here we delve into std::inserter. We’ll start with a basic question concerning how it can work, have a peek at the inside, and answer that question. This will make us better understand […]

Sorting with the STL algorithms

Published October 3, 2017 - 1 Comment

C++ offers more functionalities about sorting that meets the eye. Let’s see what the STL and Boost can do on this topic. Sorting a whole range The standard function to sort a whole range is std::sort. It operates in O(n*log(n)) and applies the sort directly on the passed range. The comparison used is operator< by default, […]

tee: Debug Info With Little Impact On Code

Published September 29, 2017 - 9 Comments
tee C++ debug log

I’d like you to meet tee, a little companion for retrieving targeted runtime info, with very, very little impact on the code. It’s simple, but I find it very convenient. You can put tee in your code wherever you need to know what’s going on, and tee will spy it for you. Its most basic implementation is […]

The Expressive C++17 Coding Challenge

Published September 25, 2017 - 12 Comments
Expressive C++17 coding challenge

The ink is dry on C++17! Actually it had dried a few times already. But the drier the ink, the sooner we get to use this new standard in production code. Now how do we learn all those new additions to the language? And how do we know to use them to write even more […]

How to implement the pimpl idiom by using unique_ptr

Published September 22, 2017 - 12 Comments

The pimpl, standing for “pointer to implementation” is a widespread technique to cut compilation dependencies. There are a lot of resources about how to implement it correctly in C++, and in particular a whole section in Herb Sutter’s Exceptional C++ (items 26 to 30) that gets into great details. There is one thing that I’ve found […]

Cppcast: A Show for All C++ Developers

Published September 19, 2017 - 2 Comments

I had the privilege to be a guest on CppCast last week. On top of sharing this episode with you, I’d like to take a moment to describe why I think the show can be useful to you as a C++ developer. I’ll share my perspective both as a regular listener and as a guest […]

1 2 3 10