Templates and metaprogramming considered as the big bad wolf of C++, and it s time to stop being scared of this wolf, as it s one of the most powerful creatures of C++. In this talk I ve demonstrated the power of this incredible creature, while I hope that this talk would be an easy enterence to this Continue reading Talk: Who s Afraid of the Big Bad Template
Learn the ways to iterate in a reverse order on a container - C++11 to C++20 with a custom, easy to use, method to allow a reverse iterations in a simple way prior to C++20 and without the ranges library.
In C++, Argument-Dependent Lookup (ADL) can be a tempting feature to use for cleaner code, but its reliance on context-specific resolution often leads to unexpected behavior. While ADL may seem like an elegant shortcut for function resolution, it can introduce ambiguity and make debugging significantly more challenging. In this article, we explore why you should avoid using ADL in favor of more…
The comma operator in C++ allows you to evaluate two expressions in a single statement. It evaluates the first expression, discards its result, and then evaluates the second expression, returning its result. While this operator can enhance coding efficiency, it can also lead to unclear code and potential pitfalls if misused, making it important to use it judiciously in your programs. To explore…
Daisy Hollman is an extremely talented developer, who is highly involved in many advanced fields of C++. She is a very close friend of mine, and I highly encourage you to go and check her stream: Good luck Daisy 🩷
const qualifier not always work the way we expect it to. In this article we will see some cases when the const doesn't protect us from modifications at all.
std::string_view can optimize both performance and code readability in code sections which handle strings. However it can also lead to UB and to memory issues if used incorrectly.
explicit(bool) C++20 feature discussion, motivation, usage example, proposal and more. Basic explanation about explicit and implicit conversions pros and cons.
You can now discuss about new articles, offer ideas for the next posts, and get updates about the blog on our new Discord server and Telegram channel. Stay tuned!
The Shared View riddle solution. Involves usage example of shared_ptr aliasing constructor, design patterns reflection and factory, metaprogramming, string_view and variant/visit.
How to save bytes and alignment when containing some types inside a structure. Techniques to avoid wasting space on unique_ptr deleter and on another structures allocators like std vector or map. Taking into account Empty Base Optimization (EBO) and no_unique_address attribute sice C++20. Internal GCC and LLVM compilers implementations.
unique_ptr and weak_ptr constructors, initializers and usage examples. make_unique advantages and disadvantages. unique_ptr custom deleters usage examples and important notes to pay attention to.
Shared ptr allocations, initializations, and behind the scenes functionality. Constructors' usage summaries, the aliasing conatructor, make_shared allocate_shared advantages and disadvantages.
Smart memory management - the ability to maintain pointers "without worrying when they should be released" sounds really utopic, but is it really the entire truth about "smart pointers"?
One of the most desired Design Patterns is reflection- The ability to use classes metadata (names, functions, properties, etc...) at runtime. By default this is not possible on C++, and sometimes the selected solution is to use macros, but today we are going to archive it without them.
Design Patterns were always different in C++, and a usual use of these patterns in C++ might cause more complications and problems in this language. In this series of articles, I’ll show how to correctly implement them in C++. In this article we’ll see how to implement a compile-time Decorator.
Design Patterns were always different in C++, and a usual use of these patterns in C++ might cause more complications and problems in this language. In this series of articles, I'll show how to correctly implement them in C++. In this article we'll see how to build a factory for a template base class.
Conditions are the most natural way to control your code flow in programming, it's almost the first thing that every programmer learn at the beginning. Sometimes conditions, especially if you are conditioning strings in C++, the code become very complicated to understand and very lazy. Let's break this pattern.
One of the first mistakes that every developer doe is to believe in the theoretical idea that behind "Random". The absolutely unexpected arbitrary result of some unexpected mysterious function. What random really is, and how do we use it the right way on C++?
How many times you find yourself writing hard-coded numbers inside your code, while trying to make sure as much as you can to make these numbers' units visible? You probably found yourself mentioning the units as part of the variable name, or at the comment, praying that who ever gets to your code will understand it. After reading this article, you will have the most maintainable way of doing so.
The third part of the iterators series. Maintain your iterations with your own containers collections. How can you create an iterators friendly collection to fit your legacy iterators-friendly code infrastructure? Create new custom iterator types in C++20.
The second part of the iterators series. Iterators might be a dangerous thing sometimes. What is the risk they bring with them, and how to prepare to / deal with it?
The first part of iterators explanation. Why should you use iterators? Which kinds of iterators exist? How can iterators help you to maintain and optimize your code? And what is the secret behind iterators?
The second part of lambda expressions explanation. Behind the scenes of lambda expressions: What lambda expressions truly are? How can they capture variables? How can we use auto params in C++14 lambdas when this feature came only in C++20? Behind the scenes from C++11 to C++20 of lambdas.
Lambda expressions usages in C++ since C++11 to C++20. Features, rules, usages and abilities. Why do we need it, and how can we get more maintainable code by using it?
How to create a collection of a template base class? How to create a single collection for multiple similar interfaces? Based on Sean Parent talk "Inheritance Is The Base Class of Evil".
The 10th post in C++ meta programming series. How to use compile-time functions from C++11 to C++20? How to define user-defined compile-time types? What is constexpr and how does it tie up all of the above?
The 9th post in C++ meta programming series. How to protect our solution from less experienced developers in variadic template development cases? Restrictions over variadic params from C++11 to C++20.
The 8th post in C++ meta programming series. What is the problem with a generic solution? Why should we pay extra attention when we solve a problem in a generic way? And how to protect our solution from less experienced developers?
The 7th post in C++ meta programming series. Learn about variadic templates in C++17- How does C++17 helps us handle them, when to use / don't use fold expressions, and what things we need to draw a close attention to when we use them?
The 6th post in C++ meta programming series. Learn about variadic templates- How to use them, and about how to make the code more flexible and maintainable with them.
This is the 5th post in C++ meta programming series. Learn about explicit partial template specializations in C++, and about the differences between them.
Separation of templates functions/classes declarations from definitions always raise a common issue at the first time. Read about the reasons for this issue, and how to solve it.
This is the third post in C++ meta programming series. Learn about basic non-type template parameters, template of templates, and passing functions as template parameters.
This is the second post in C++ meta programming series. Learn about basic templates usage, why it's needed, and how can it help you writing a generic code.
Why does C++ meta programming is so important and powerful? This is a short introduction to C++ meta programming, it's abilities, and strengths. The first article in a series about C++ meta programming.
You got an idea, know some languages, have some techniques, so what are you waiting for?! Go and code up your idea! But Is there a better/right way? Should you take something into consideration before? Will there be consequences? Before you start coding your idea, it s better to read this post, just to make sure Continue reading Before starting a new project The Most Important Decision