std::literals::chrono_literals(3cxx)
π NAME π
std::literals::chrono_literals β bestie, this is the 3cxx manual page for the ISO C++ 2014 namespace that hands you the cute little suffixes you slap on number literals to make chrono::duration values. No cap.
β¨ SYNOPSIS β¨
okay so this namespace is just a big pile of overloaded operator'' friends, and here's literally every single one of them, no skipping π«Ά
π Functions
template<char... _Digits> constexpr chrono::hours operator''h ()β Literal suffix for durations of typestd::chrono::hoursconstexpr chrono::duration< long double, ratio< 3600, 1 > > operator''h (long double __hours)β Literal suffix for durations representing non-integer hours.template<char... _Digits> constexpr chrono::minutes operator''min ()β Literal suffix for durations of typestd::chrono::minutesconstexpr chrono::duration< long double, ratio< 60, 1 > > operator''min (long double __mins)β Literal suffix for durations representing non-integer minutes.template<char... _Digits> constexpr chrono::milliseconds operator''ms ()β Literal suffix for durations of typestd::chrono::millisecondsconstexpr chrono::duration< long double, milli > operator''ms (long double __msecs)β Literal suffix for durations representing non-integer milliseconds.template<char... _Digits> constexpr chrono::nanoseconds operator''ns ()β Literal suffix for durations of typestd::chrono::nanosecondsconstexpr chrono::duration< long double, nano > operator''ns (long double __nsecs)β Literal suffix for durations representing non-integer nanoseconds.template<char... _Digits> constexpr chrono::seconds operator''s ()β Literal suffix for durations of typestd::chrono::secondsconstexpr chrono::duration< long double > operator''s (long double __secs)β Literal suffix for durations representing non-integer seconds.template<char... _Digits> constexpr chrono::microseconds operator''us ()β Literal suffix for durations of typestd::chrono::microsecondsconstexpr chrono::duration< long double, micro > operator''us (long double __usecs)β Literal suffix for durations representing non-integer microseconds.
πΈ Detailed Description πΈ
ISO C++ 2014 namespace for suffixes for duration literals. it's giving "time math but make it aesthetic" β°β¨
These suffixes can be used to create chrono::duration values with tick periods of hours, minutes, seconds, milliseconds, microseconds or nanoseconds. For example, std::chrono::seconds(5) can be written as 5s after making the suffix visible in the current scope. The suffixes can be made visible by a using-directive or using-declaration such as:
using namespace std::chrono_literals;using namespace std::literals;using namespace std::chrono;using namespace std;using std::chrono_literals::operator''s;
The result of these suffixes on an integer literal is one of the standard typedefs such as std::chrono::hours. The result on a floating-point literal is a duration type with the specified tick period and an unspecified floating-point representation, for example 1.5e2ms might be equivalent to chrono::duration<long double, chrono::milli>(1.5e2).
lowkey important: for the floating-point ones, the representation is unspecified β the page says "might be equivalent", so don't go writing code that hard-depends on it being exactly that type, bestie π
π Author π
Generated automatically by Doxygen for libstdc++ from the source code. yeah, a robot wrote it, but the vibes? immaculate. π€π
and that's the whole page!! this one came straight out of the <b>libstdc++</b> docs, section <b>3cxx</b>, footer reading libstdc+std::literals::chrono_literals(3cxx) β go forth and 5s, 1.5e2ms, and generally live your main character timekeeping era π¦β±οΈπ
π¦ where this page comes from
- ubuntu noble: libstdc++-11-doc 11.4.0-9ubuntu1
- ubuntu noble: libstdc++-11-doc 11.5.0-1ubuntu1~24.04.1
- ubuntu questing: libstdc++-11-doc 11.5.0-7ubuntu1
- ubuntu questing: libstdc++-11-doc 11.5.0-7ubuntu1.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms