...

/

User-Defined Literals: Introduction

User-Defined Literals: Introduction

In this lesson, we will introduce user-defined literals.

User-Defined Literals

User-defined literals are a unique feature in all mainstream programming languages, since they enable us to combine values with units.

widget

Syntax

Literals are explicit values in a program, including a boolean like true, the number 3 or 4.15; the char a, or the C string "hello". The lambda function [](int a, int b){ return a+b; } is also a function literal.

With C++11, it is possible to generate ...