Jonathan Boccara's blog

A new post every Tuesday and Friday morning

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

How to Make Custom Deleters More Expressive

Published September 1, 2017 - 3 Comments

Most of the times where we use std::unique_ptr, we’re fine without using a custom deleter. But sometimes, a custom deleter offers a way out of a tricky situation. Now that we’ve seen how to use custom deleters and when they can be useful, I would like to share with you a technique to make their usage […]

Smart developers use smart pointers (3/7) – Custom deleters

Published August 29, 2017 - 13 Comments

The previous episodes of the series explained what smart pointers are, and which ones to use in your code. Here I show a technique that allows to encapsulate complex memory management into std::unique_ptr, to relieve your code from low-level memory manegement. The series Smart developers use smart pointers contains: Smart pointer basics unique_ptr, shared_ptr, weak_ptr, scoped_ptr, […]

unique_ptr, shared_ptr, weak_ptr, scoped_ptr, raw pointers – Knowing your smart pointers (2/7)

Published August 25, 2017 - 7 Comments

This is episode 2 in y  series Smart Developers Use Smart Pointers. The series contains: Smart pointer basics unique_ptr, shared_ptr, weak_ptr, scoped_ptr, raw pointers: clearly stating your intentions by knowing your smart pointers Custom deleters and How to make them more expressive Changing deleters during the life of a unique_ptr How to implement the pimpl idiom […]

How to Handle Multiple Types in Max Without A Cast

Published August 18, 2017 - 4 Comments

Today I want to share with you an interesting technique shown by Arthur O’Dwyer in his CppCon talk, Template Normal Programming, to deal with min and max on different types. Arthur has kindly accepted that I share this content with you on Fluent C++. This will be a shorter post, fit for summer as you […]

Function Templates Partial Specialization in C++

Published August 15, 2017 - 5 Comments

Why doesn’t C++ allow partial specialization on function templates? Such was the question I asked to you, readers of Fluent C++, in the post covering Template Partial Specialization. Not because I wanted to test you, but simply because I couldn’t find the answer. And oh boy did I get an answer. The post received comments, questions, […]