💻 C++ Tricks for C Programmers
C++ offers developers modern tools to leverage when designing more reusable, scalable, and portable code.
▫️ Conditional Compilation Using Constexpr: The bane of many embedded code bases written in C is the large numbers of #if / #elif / #else preprocessor directives. Starting in C++ 17, the language introduced the ability for developers to conditionally compile code using constexpr.
▫️ Ranged for Loops: The C for loop has been stuck in the dark ages by not having a simplified range-based option. Starting in C++ 11, an additional version of the for loop was added that makes working with ranged values easier.
▫️ Use Auto: C developers used to use auto to specify a variable that was limited to the current scope. In C++, auto can be a very useful keyword that tells the compiler to automatically assign the datatype for the developer.
▫️ The Spaceship Operator: Just recently, C++ 20 add a three-way comparison operator <=> that can simplify readability and the code.
#articles
C++ offers developers modern tools to leverage when designing more reusable, scalable, and portable code.
▫️ Conditional Compilation Using Constexpr: The bane of many embedded code bases written in C is the large numbers of #if / #elif / #else preprocessor directives. Starting in C++ 17, the language introduced the ability for developers to conditionally compile code using constexpr.
▫️ Ranged for Loops: The C for loop has been stuck in the dark ages by not having a simplified range-based option. Starting in C++ 11, an additional version of the for loop was added that makes working with ranged values easier.
▫️ Use Auto: C developers used to use auto to specify a variable that was limited to the current scope. In C++, auto can be a very useful keyword that tells the compiler to automatically assign the datatype for the developer.
▫️ The Spaceship Operator: Just recently, C++ 20 add a three-way comparison operator <=> that can simplify readability and the code.
#articles
👍7