Tutorial by Examples

#include <iostream> long double operator"" _km(long double val) { return val * 1000.0; } long double operator"" _mi(long double val) { return val * 1609.344; } int main() { std::cout << "3 km = " << 3.0_km << " m...
C++14 Those following duration user literals are declared in the namespace std::literals::chrono_literals, where both literals and chrono_literals are inline namespaces. Access to these operators can be gained with using namespace std::literals, using namespace std::chrono_literals, and using names...
C++14 Those following string user literals are declared in the namespace std::literals::string_literals, where both literals and string_literals are inline namespaces. Access to these operators can be gained with using namespace std::literals, using namespace std::string_literals, and using namespa...
C++14 Those following complex user literals are declared in the namespace std::literals::complex_literals, where both literals and complex_literals are inline namespaces. Access to these operators can be gained with using namespace std::literals, using namespace std::complex_literals, and using nam...
Despite you can write a binary number in C++14 like: int number =0b0001'0101; // ==21 here comes a famous example with a self-made implementation for binary numbers: Note: The whole template expanding program is running at compile time. template< char FIRST, char... REST > struct binary {...

Page 1 of 1