What do you do when the code for a variable initialization is complicated? Do you move it to another method or write inside the current scope?
In this blog post, I’d like to present a trick that allows computing a value for a variable, even a const variable, with a compact notation.
Let’s put C++17 in practice!
One of the good ways to do it is to take part in a coding challenge.
So together with Jonathan Boccara from Fluent C++ we invite you to participate in “The Expressive C++17 coding challenge”.
The Expressive C++17 coding challenge Jonathan made a few contests on his blog (for example this one), and I thought it might be fun to do something similar for C++17.
I got very interested in one topic that recently appeared on on Andrzej’s Blog: Toggles in functions. I though that maybe is worth to express my opinion as a separate blog post.
Please take a look.
Intro As Andrzej wrote in the article the whole point is how to improve the code around functions like:
I need to confess that for the last few years I’ve been a bit obsessed with the idea of making all variables const. Whenever I declare a variable in a function body, I try to think if I can make it constant. Let me explain why I think you should be doing the same.
Since 2011, when C++11 arrived, we all should be changing our coding style into modern C++ and at the same time keep good old tips. There are also general rules for programming and bug-free coding. Here’s a list of guidelines and other resources that might help you.
Core C++ Guidelines Main site: C++ Core Guidelines