0

I see code using std::chrono that says things like:

auto tenSeconds = 10s;

I understand that Chrono defines a type s for seconds. And I understand that the type of tenSeconds becomes something like chrono::second. But isn't 10s just illegal C++? Is there some operator I can redefine that allows me to place a number right beside a string and have C++ understand?


This question has been closed. I am told that the answer is in another, previous question and answer. What new capabilities do user-defined literals add to C++?

I may just be dense, but I didn't understand until I looked in Stroustrup's book The C++ Programming Language. I guess his explanation of what was trying to be accomplished, and his breaking out operator"" as a new kind of operator did it for me.

The previous answer referenced gave me enough clues to lead me back to Stroustrup, though.

user2171796
  • 397
  • 2
  • 16

0 Answers0