C++14 Built-In Literals

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

We'll cover the following

New built-in literals in C++14 #

In C++ 14, there are a few new built-in literals including those for binary numbers, C++ strings, complex numbers, and time units. Let’s have a look at the overview of this new concept.

We must keep a few special rules in mind. There is one main difference between built-in literals and user-defined literals: built-in literals have no underscore. For the first time, in C++14, string literals are supported. In the past C++ only supported C-string literals, meaning that we had to always use a C-string literal to initialize a C++ string. Time literals are also very convenient since they implicitly know their own unit, and also support basic arithmetic. Time literals are of the type std::chrono::duration.


In the next lesson, we’ll learn two different types of literal operators.