What is the operator “” in C++?

后端 未结 2 1169
予麋鹿
予麋鹿 2020-12-25 09:46

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

The decision of the C++ standards committee to

2条回答
  •  悲&欢浪女
    2020-12-25 10:13

    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.

提交回复
热议问题