In January, I was lucky to get a relatively new book on Modern C++! This time it’s not aimed at experts but rather at the beginner level. It’s called “Modern C++ for Absolute Beginners,” written by Slobodan Dmitrović. I think it might be a valuable resource for job interviews.
Let’s see what’s inside.
Boolean parameters in a function might be misleading and decrease its readability. If you have a poorly named function like:
DoImportantStuff(true, false, true, false); As you can imagine, it’s not clear what all those parameters mean? What’s the first true? What does the last false mean? Can we improve code in such cases?
In the previous article on the tuple iteration, we covered the basics. As a result, we implemented a function template that took a tuple and could nicely print it to the output. There was also a version with operator <<.
Today we can go further and see some other techniques. The first one is with std::apply from C++17, a helper function for tuples.
If you have a standard container, it’s easy to use a range-based for loop and iterate over its elements at runtime. How about std::tuple? In this case, we cannot use a regular loop as it doesn’t “understand” tuple’s compile-time list of arguments. That’s why in this article, I’ll show you a few techniques you can use to run through all tuple’s entries.
C++20 is huge and filled with lots of large features. Just to mention a few: Modules, Coroutines, Concepts, Ranges, Calendar & Timezone, Formatting library.
But, as you know, that’s not all.
Depending on how we count, C++20 brought around 80 Library features and 70 language changes, so there’s a lot to cover :)
C++ not only grows with cool features but also improves and makes code simpler and readable. It’s evident in template code. For example, typename inside dependent names is now much easier (not) to use.
If you have an expression like X<T>::name, should you always put typename in front?
See the full details below.
I’m happy to present the 10th edition of “C++ at the end”! See what happened this year in the C++ World!
New features, plans for the language, updated tools and compilers, conferences, books, and more!
What was the most important event this year? The pandemic? C++20 adoption? Ongoing work for C++23 or something else?
It’s almost the end of the year! As usual, I started writing my “year” summary that I will publish on the 31st of December.
Yet, this article won’t be possible without your input!
I have a survey with just nine questions about C++ and your experience in 2021.
C++ Standard used Your experience with C++17, C++20 Compiler used IDE and tools Best thing that happened It should take no more than 5 minutes :)
In this blog post, I’d like to show you examples of several handy “map” functions from Modern C++. Associative containers like std::map, std::set, and their “unordered” counterparts are essential for many algorithms and techniques. With this new functionality, you can save the creation of temporary objects, write smaller and, what’s more, safer code.
Welcome to the 6th episode of C++ Links available for C++ Stories subscribers.
See the best C++ stories from the past month.
Here’s the plan for today:
C++23 progress Parsing Command Line Arguments 3 New articles at C++stories in November + 8 Hot C++ News How to write a custom iterator in C++20 Read till the end to see an additional bonus :) Let’s start!
New Standard, new ways to initialize objects!
With C++20, we get a handy way of initializing data members. The new feature is called designated initializers and might be familiar to C programmers.
Let’s have a look at this small feature:
The basics Designated Initialization is a form of Aggregate Initialization.
Would you like to gain 20…35 or even 50% speed improvements when searching in associative containers? In this blog post, we’ll explore a technique called “heterogenous access” that offers such impressive speedups. We’ll explore ordered containers, and the support for unordered collections added recently in C++20.
Recap on heterogeneous lookup in ordered containers Let’s bring the example and have a look at how this feature works for ordered containers.