From dynamic container operations to compile-time constants, C++ offers a variety of techniques. In this article, we’ll delve into advanced initialization methods likereserve()
and emplace_back
for containers to tuples with piecewise_construct
and forward_as_tuple
. Thanks to those techniques, we can reduce the number of temporary objects and create variables more efficiently.
Five Advanced Initialization Techniques in C++: From reserve() to piecewise_construct and More
By Bartlomiej Filipek
From the article:
As a background, we can use the following class that will be handy to illustrate when its special member functions are called. That way, we’ll be able to see extra temporary objects.
Add a Comment
Comments are closed.