A new post every Tuesday and Friday morning

How to implement the pimpl idiom by using unique_ptr

Published September 22, 2017 - 10 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 […]

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

1 2 3 9