Built-in Literals

A shorthand introduction to the new built-in literals in C++ 14.

We'll cover the following

New Built-in Literals with C++14

In C++ 14, there are a few new built-in literals. These are built-in literals for binary numbers, C++ strings, complex numbers, and time units. At first, let go over an overview of this new concept.

You must keep a few special rules in mind. There is a main different between the built-in literals and the user-defined literals: the built-in literals have no underscore. For the first time, C++ supports (with C++14) a C++ string literal. So far, C++ only supported C-string literals, meaning that we must always use a C-string literal to initialize a C++ string. The time literals are also very convenient since they implicitly know their unit and support basic arithmetic. They are of the type std::chrono::duration.

Get hands-on with 1000+ tech skills courses.