
C++


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.[…]