3
votes

chrono takes user-defined literals to make it more convenient. For each literal, it has two overloading functions.

constexpr chrono::hours operator "" h(unsigned long long);
constexpr chrono::duration<unspecified , ratio<3600,1>> operator "" h(long double);

I'm confused by the second overloading function, i.e. the function with long double as parameter.

Why we need the second overloading? And what is unspecified?

1
See this documentation for why the two overloads exist. As for the unspecified it is implementation defined - Remy Lebeau
This is the exact answer. Thanks a lot! - for_stack

1 Answers

3
votes

Both represent std::chrono::duration in hours. The first one forms an integer literal, the second one forms a floating-point literal. First one can represent tick count only, the second one can represent fractions of ticks.