Jonathan Boccara's blog

Simplicity in C++ Code (Podcast)

Published July 20, 2018 - 1 Comment

Last week, Jon Kalb and Phil Nash, the organizers of C++Chat, invited Kate Gregory and I on the show to discuss “Simplicity” in C++ code, and in designing code in general. We had a very interesting discussion, that includes topics such as: how to measure complexity, coupling in code, levels of abstraction, the hard decisions […]

How to Construct C++ Objects Without Making Copies

Published July 17, 2018 - 19 Comments

Today’s guest post is written by guest author Miguel Raggi. Miguel is a Computer Science and Math professor at UNAM, Mexico’s largest university. He loves clean, expressive, performant C++ code (and strives to convince students to write it in this way!). Miguel is the author of discreture, an open source C++ library to efficiently generate […]

The Incredible Const Reference That Isn’t Const

Published July 13, 2018 - 23 Comments
cont reference not const

While working on the NamedType library I came across a situation that left me stunned in bewilderment: a const reference that allows modification of the object it refers to. Without a const_cast. Without a mutable. Without anything up the sleeve. How can this be? And how to enforce the const in that const reference? A const reference […]

105 STL Algorithms in Less Than an Hour

Published July 10, 2018 - 0 Comments
105 STL algorithms in less than an hour

Everyone knows that it’s a good thing to know the STL algorithms. But do know each and every one of them? To learn all there is in the STL algorithms library, I’ve presented a talk at several conferences this year, that was titled 105 STL Algorithms in Less Than an Hour. The point of this […]

The World Map of C++ STL Algorithms

Published July 6, 2018 - 5 Comments
world map C++ STL algorithms

We all know that we should know our STL algorithms, because they help make our code more expressive and more robust (sometimes in spectacular ways!). But do you know all your STL algorithms? There are 105 of them if we include those of C++17, and every one of them has a chance to be useful […]

How to Reduce the Code Bloat of a Variadic CRTP

Published July 3, 2018 - 3 Comments

In the previous post we’ve seen how to introduce variadic templates into the CRTP pattern, and how it allowed to create classes with various sets of opt-in features. For instance, the class X would have a basic interface but also augment them by inheriting from a set of CRTP base classes: template<template<typename> typename… Skills> class X […]

Variadic CRTP Packs: From Opt-in Skills to Opt-in Skillsets

Published June 26, 2018 - 2 Comments

Last week we’ve seen the technique of the variadic CRTP, that allowed to plug in generic extra features to a class. For instance, we’ve seen the following class X: template<template<typename> typename… Skills> class X : public Skills<X<Skills…>>… { public: void basicMethod(); }; X can accept extra features that plug into its template parameters: using X12 = […]

3 Simple C++17 Features That Will Make Your Code Simpler

Published June 19, 2018 - 0 Comments

This article is a guest post written by guest author jft. C++17 has brought a lot of features to the C++ language. Let’s dig into three of them that help make coding easier, more concise, intuitive and correct. We’ll begin with Structured Bindings. These were introduced as a means to allow a single definition to […]