Jonathan Boccara's blog

How to Check If 2 Sorted Collections Have a Common Element

Published July 3, 2020 - 0 Comments

Ah, the algorithms on sets! Such beautiful algorithms, and so useful too. The algorithms on sets are basically the algorithms that take sorted collections and compare them in linear time. The STL offers five algorithms on sets: std::set_difference, std::set_intersection, std::set_union, std::set_symmetric_difference, and std::includes. If you’re a C++ developer, you absolutely, positively, unquestionably need to know […]

A Universal Reference Wrapper

Published June 26, 2020 - 0 Comments

This is a guest post by Ábel Surányi. Ábel is working as a software engineer in the IT security industry. He likes generic and functional programming, especially building abstractions by translating an idea to code in a way that the compiler can understand and catches errors during compilation. You can find Ábel on LinkedIn or on his […]

Great Developers Don’t Just Write Great Code

Published June 19, 2020 - 0 Comments

I’m assuming that, if you’re reading this, you are aspiring to become a good developer. But what is a good developer, to begin with? Let’s reflect on what we need to do in our jobs as software developers to identify what is important–and therefore what we have to master in order to become “good developers”. […]

A Generic Component for Out-of-line Lambdas

Published June 12, 2020 - 0 Comments

When exploring out-of-line lambdas, we saw how we could make a call site using a lambda more expressive by hiding the lambda in a separate function. We transformed this code that shows low-level details: auto const product = getProduct(); std::vector<Box> goodBoxes; std::copy_if(boxes.begin(), boxes.end(), std::back_inserter(goodBoxes), [product](Box const& box) { // low-level details const double volume = […]

Out-of-line Lambdas

Published June 5, 2020 - 0 Comments

Lambdas are a great tool to make code more expressive. Except when they aren’t. With C++11 bringing them to the language, we were given the liberating power to create anywhere those little functions embarking bits of context. Sometimes they make our code terse and to the point. But sometimes, they sit in the middle of […]

Going Far into Polymorphic Helpers

Published May 29, 2020 - 0 Comments

When we saw How to Assign Derived Classes in C++, we came up with a technique involving runtime polymorphism mixed with CRTP. This allowed derived classes to benefit from a polymorphic assignment operator without implementing it themselves, thus reducing boilerplate code. But assignment is just a special case of a polymorphic function to implement on a […]

How to Assign Derived Classes in C++

Published May 22, 2020 - 0 Comments

A classical problem in object-oriented programming, and with polymorphism in general, is to handle multiple polymorphic objects at the same time. In other terms, multiple dispatch. An associated problem with object-oriented programming is that many languages, including C++, don’t implement multiple dispatch. One case comes up often: handling the behaviour of two objects of the […]

Runtime Polymorphism Without Objects or Virtual Functions

Published May 15, 2020 - 0 Comments

When thinking of polymorphism, and in particular of runtime polymorphism, the first thing that comes to mind is virtual functions. Virtual functions are very powerful, and fit for some use cases. But before using them, it’s a good thing to consider our exact need for polymorphism, and look around if there are other, more adapted […]

Evaluating user-defined logical expressions

Published May 8, 2020 - 0 Comments

This is a guest post by Marin Peko. Marin is a Software Engineer working at Cellusys, a company providing telecommunication solutions, and follower of Fluent C++. You can find him on LinkedIn and Github. Logical expressions are probably one of the most used concepts in computer science and certainly a large part of each code […]

1 7 8 9 10 11 45