cpp generics

generics

variadic template parameter

1
2
3
4
5
template<typename... Types>
void printValues(const Types&... values) {
// Fold expression (C++17 and later) to print all values
(std::cout << ... << values) << std::endl;
}

macros

examples

1
2
3
#if defined(_WIN32)
#else
#endif
  • __cplusplus macro is a predefined macro in C++ that is used to indicate the version of the C++ standard being used by the compiler. The value of __cplusplus is an integer that represents the version.
  • FILE
    __FILE__ is a predefined macro in C and C++ that expands to the name of the current source file as a string literal.
  • LINE
    __LINE__ is a predefined macro in C and C++ that expands to the current line number in the source code.