C++ Variadic Parameters: The Safe Evolution from C-style Pitfalls to Modern Solutions

Recently, I stumbled upon the use of std::print in C++ code, which intrigued me. I wondered how C++ had adopted the printf mechanism from C, especially since there is cout. After looking at a few examples, I realized the brilliance of this new method, which provides a more concise and convenient formatting output than cout … Read more

New Features in C++26: Static Storage with Braced Initializers

New Features in C++26: Static Storage with Braced Initializers

1. Initialization with Braces Using braces for initialization, specifically with std::initializer_list for list initialization, makes the entire program clearer and simpler to implement. However, various situations can arise during this implementation. Although a temporary array is generated for data storage in general, the details of its implementation differ in various cases. With the evolution of … Read more

Uniform Initialization in C++: The Power of Braces

Uniform Initialization in C++: The Power of Braces

When writing C++, do you often find yourself struggling with whether to use <span>=</span> or <span>()</span> to initialize variables? Sometimes you write it as <span>int a = 10;</span> Other times you write it as <span>std::string s("hi");</span> Can class member variables only be initialized through constructors? 🤯 To address the above issues, C++11 introduced a powerful … Read more