
C++


Beautiful code #3 - [[no_unique_address]] - sophisticated and simple C++20 featureπ
[[no_unique_address]]
is a C++ 20 feature that helps in saving memory while declaring an empty struct or class and creating object for it in some other place.

Beautiful code #2 - enable_if_t and template inside a template code π
In this short article, I have posted a code snippet that uses enable_if_t
to handle SFINAE and also showed how to use a template inside a template.

Beautiful code #1 - Using define, templates and r-value reference π
In this short article, I have posted an example that does the reinterpret_cast
on an integer and convert it to char pointer and then the value pointed by the char pointer is converted to r-value reference all in a macro.

Enumerations and Class Enumerations in C++ π
Enumerations are always fun to use in C++ programs. C++ core guidelines define eight different rules to define the enumerations. And also, C++11 introduced the scoped enumerations also called as class enumerations. Scoped enums also have few advantages over plain enums which are also covered in this article.

Function Templates in C++ π
Overloaded functions have the exact same code but the type is different. It seems an unnecessary overhead to write the same code again and again and in a long time it adds up to the maintenance cost of the project. To write code once and use it multiple times we use function templates. A function template is itself is not a definition of a function; it is a blueprint for defining a family of functions.

Volatile Keyword in C and C++ π
Quoting from the C++ Standard ($7.1.5.1/8):
[..] volatile is a hint to the implementation to avoid aggressive optimization involving the object because the value of the object might be changed by means undetectable by an implementation.[β¦]" lead: “Quoting from the C++ Standard ($7.1.5.1/8)
[..] volatile is a hint to the implementation to avoid aggressive optimization involving the object because the value of the object might be changed by means undetectable by an implementation.[β¦]