Runtime polymorphism usually connects with v-tables and virtual functions. However, in this blog post, I’ll show you a modern C++ technique that leverages std::variant and std::visit. This C++17 technique might offer not only better performance and value Read Full
Tag: Cpp
C++20 Ranges, Projections, std::invoke and if constexpr
Continuing the topic from last week, let’s dive into the topic of std::invoke. This helper template function helps with uniform syntax call for various callable object types and can greatly reduce the complexity of our generic code. Read Full
17 Smaller but Handy C++17 Features
When you see an article about new C++ features, most of the time you’ll have a description of major elements. Looking at C++17, there are a lot of posts (including articles from this blog) about structured bindings, Read Full
How To Stay Sane with Modern C++
C++ grows very fast! For example, the number of pages of the C++ standard went from 879 pages for C++98/03 to 1834 for C++20! Nearly 1000 pages! What’s more, with each revision of C++, we get several Read Full
How to Pass a Variadic Pack as the First Argument of a Function in C++
Variadic templates and argument packs which are available since C++11 give flexibility in situations when you don’t know the number of inputs upfront. However, they are limited and can only appear at the end of the type Read Full
How I Improved My Legacy C++ Project with PVS-Studio
Since a few months, I’ve been refactoring my old C++/OpenGL project. Thus far, I used compilers (MSVC and Clang), my knowledge or free tools. At some point, I also got a chance to leverage a solid static Read Full
Replacing unique_ptr with C++17’s std::variant a Practical Experiment
Some time ago I wrote about a new way to implement runtime polymorphism which is based not on virtual functions but on std::visit and std::variant. Please have a look at this new blog post where I experiment Read Full
6 Efficient Things You Can Do to Refactor a C++ Project
I took my old pet project from 2006, experimented, refactored it and made it more “modern C++”. Here are my lessons and six practical steps that you can apply in your projects. Let’s start Background And Test Read Full
C++17: Polymorphic Allocators, Debug Resources and Custom Types
In my previous article on polymorphic allocators, we discussed some basic ideas. For example, you’ve seen a pmr::vector that holds pmr::string using a monotonic resource. How about using a custom type in such a container? How to Read Full
How to Check String or String View Prefixes and Suffixes in C++20
Up to (and including) C++17 if you wanted to check the start or the end in a string you have to use custom solutions, boost or other third-party libraries. Fortunately, this changes with C++20. See the article Read Full
C++ Lambda Week: Some Tricks
We’re on the last day of the lambda week. We have all the essential knowledge, and now we can learn some tricks! The Series This blog post is a part of the series on lambdas: The syntax Read Full
C++ Lambda Week: Going Generic
We’re in the third day of the lambda week. So far, you’ve learned basic syntax and how to capture things. Another important aspect is that lambdas can also be used in the “generic” scenarios. This is especially Read Full
- 1
- 2