Jonathan Boccara's blog

A new post every Tuesday and Friday morning

How the STL inserter iterator really works

Published October 6, 2017 - 1 Comment

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

How to Return a Smart Pointer AND Use Covariance

Published September 12, 2017 - 10 Comments

Today we’re going to take a big step back on the specific problem of the clone interface we’ve dealt with on the last post. For this Raoul Borges is taking over on this topic to show you a solution to the general problem of smart pointers and covariance in C++. Raoul is a C++ developer […]

Polymorphic clones in modern C++

Published September 8, 2017 - 3 Comments

How to copy an object that is accessible only by an interface that it implements? This question has been around for a very long time, and is associated with a classical solution described by Scott Meyers in Item 25 of More Effective C++. This solution still works, but can benefit from modern C++ features that weren’t in the […]

Changing deleters during the life of a unique_ptr (4/7)

Published September 5, 2017 - 2 Comments

A previous episode in the Smart developers use Smart pointers series showed how (and why) to use custom deleters in std::unique_ptr. Now let’s see the methods that change the custom deleter during the life of the unique_ptr and, also, those that don’t. This aspect of smart pointers has been pointed out to me by Mathieu Ropert and Raoul Borges. Thanks guys. The […]

1 3 4 5 6 7 14