|
|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Member functions | ||||
| Nonmember functions | ||||
operator<< | ||||
| Helper classes | ||||
(C++26) |
Defined in header <chrono> | ||
template<class CharT,class Traits> std::basic_ostream<CharT, Traits>& | (since C++20) | |
Forms astd::basic_string<CharT>s consisting of the day value stored ind formatted as a decimal number, with a leading zero if the result would otherwise be a single decimal digit. Then, if!d.ok(), append" is not a valid day" to the formatted string. Inserts that string intoos.
Equivalent to
return os<<(d.ok()?
std::format(STATICALLY_WIDEN<CharT>("{:%d}"), d):
std::format(STATICALLY_WIDEN<CharT>("{:%d} is not a valid day"), d));
whereSTATICALLY_WIDEN<CharT>("...") is"..." ifCharT ischar, andL"..." ifCharT iswchar_t.
os
#include <chrono>#include <iostream> int main(){constexprstd::chrono::day d1{31}, d2{7}, d3{42}, d4{};std::cout<< d1<<'\n'<< d2<<'\n'<< d3<<'\n'<< d4<<'\n';}
Possible output:
310742 is not a valid day00 is not a valid day
(C++20) | stores formatted representation of the arguments in a new string (function template)[edit] |
formatting support forday(class template specialization)[edit] |