close
The Wayback Machine - https://web.archive.org/web/20220501144451/https://www.fluentcpp.com/
Image

Jonathan Boccara's blog

Image

Copy-Paste Developments

Published April 26, 2022 - 0 Comments

Amongst the many tasks a programmer does, one of them is to add a new feature in a location of the application where there are already many similar exising features. The temptation is then to warm up very specific muscles of our left hand: the pinky muscles that will press on the Ctrl key, the […]

Design Patterns VS Design Principles: Abstract Factory

Published April 6, 2022 - 0 Comments

In the “Design Pattens VS Design Principles” series, we look at design patterns and relate them to design principles. In this episode, we examine the Abstract Factory pattern. Let’s see how Abstract Factory works and what it is useful for, then relate it to a design principle. We will also see a C++ technique to […]

How to Generate All the Combinations from Several Collections

Published March 18, 2022 - 0 Comments

Generating all the possible combinations from a set of collections and applying a function to each combination is a need that comes up often in programming. This is called a “Cartesian product”. For example, this kind of operation is necessary in the cartesian_product range adaptor, in the cartesian_product pipe, and in the killer feature of […]

Code It Yourself: Generate All the Combinations from Several Collections

Published March 14, 2022 - 0 Comments

A Cartesian product consists in applying a function to all the possible combinations of the elements of several collections. For example, consider the three following collections: auto const inputs1 = std::vector<int> {1, 2, 3}; auto const inputs2 = std::vector<std::string>{“up”, “down”}; auto const inputs3 = std::vector<std::string>{“blue”, “red”}; Then (2, up, blue) and (3, up, red) are two of […]

Design Patterns VS Design Principles: Visitor

Published February 9, 2022 - 0 Comments

In today’s episode of the series “Design Pattens VS Design Principles”, we’re focusing on the last behavioural design pattern: Visitor, and see how it relates to the High Cohesion design principle. The GoF meets the GRASP If you’re just joining the series, The GoF meets the GRASP is about relating each of the GoF design […]

The Interesting Evolution of std::equal_range

Published January 10, 2022 - 0 Comments

The good old std::equal_range STL algorithm, which has been in the STL since C++98, has evolved along with the versions of C++. Starting from a poor interface and now a much better one, its story is an interesting example of how to improve the abstraction of an interface. (Good?) old C++98 equal_range The first version of […]

A Simple Habit to Avoid Complex Names and Typos in Code

Published December 27, 2021 - 0 Comments

Don’t you find it a little unsettling when you encounter a typo in code? std::unordered_map<int, Value> MyClass::getInedxedValues() const { // … } And the code looks even more careless when that typo is repeated several times across the codebase, in code that depends on the butchered symbol: auto const table1 = x.getInedxedValues(); auto const table2 […]

The Evolutions of Lambdas in C++14, C++17 and C++20

Published December 13, 2021 - 0 Comments

Lambdas are one of the most popular features of Modern C++. Since their introduction in C++11, they’ve become ubiquitous in C++ code. But since their appearance in C++11, they have evolved and gained significant features. Some of those features help write more expressive code, and since using lambdas is so common now, it is worth […]

1 2 3 44