58

I fell on this page where the author talks about the standardisation of the operator "":

The decision of the C++ standards committee to standardise operator "" was [...]

What is he/she talking about? I can't find any information about this, and I don't understand what it could imply (overload for constant strings? Or something more conceptual, that doesn't affect the final use of the language?)

Toby Speight
  • 27,591
  • 48
  • 66
  • 103
yolenoyer
  • 8,797
  • 2
  • 27
  • 61

2 Answers2

68

Those are user-defined literals. They allow you to create stuff like std::string, std::chrono::durations or any user defined type (you can make your own literals) in place:

auto str = "Hello"s; // str is std::string("Hello")
auto sec = 5s;       // sec is 5 std::chrono::seconds

A list of the literal-operators provided by the standard library and their documentation can be found at the bottom of the documentation page I linked.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Baum mit Augen
  • 49,044
  • 25
  • 144
  • 182
3

It's the user-defined literal operator which will allow the introduction of new literal syntax based on existing literals.

For more information, show this reference link.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
msc
  • 33,420
  • 29
  • 119
  • 214