std::chrono...rono::month)(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

okay bestie, welcome to the std::chrono...rono::month)(3) page from the C++ Standard Libary manual β€” yes, we're doing chrono month stream-out energy today πŸ’–βœ¨

πŸŽ€ NAME πŸŽ€

std::chrono::operator<<(std::chrono::month) β€” literally std::chrono::operator<<(std::chrono::month), no cap. It's the overload that streams a std::chrono::month.

✨ Synopsis ✨

Defined in header <chrono>.

This overload is (since C++20) and the signature is giving template realness:

template< class CharT, class Traits >

std::basic_ostream<CharT, Traits>&
    operator<<( std::basic_ostream<CharT, Traits>& os, const std::chrono::month& m );

If !m.ok(), it inserts unsigned(m) followed by " is not a valid month" into os.

Otherwise, it forms a std::basic_string<CharT> s consisting of the abbreviated month name for the month represented by m, determined using the locale associated with os, and inserts s into os.

Equivalent to:

return os << (m.ok() ?
    std::format(os.getloc(), STATICALLY_WIDEN<CharT>("{:L%b}"), m) :
    std::format(os.getloc(), STATICALLY_WIDEN<CharT>("{} is not a valid month"),
unsigned(m)));

where STATICALLY_WIDEN<CharT>("...") is "..." if CharT is char, and L"..." if CharT is wchar_t.

🫢 Return value 🫢

It returns os. that's it, that's the whole return value bestie πŸ’…

πŸ’… Notes πŸ’…

This operator<< is primarily intended for debugging use. For control over formatting, use std::format.

πŸ“‹ Defect reports πŸ“‹

The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

  • P2372R3 β€” Applied to: C++20
    • Behavior as published: the given locale was used by default
    • Correct behavior: L is needed to use the given locale

🌈 See also 🌈

  • format β€” stores formatted representation of the arguments in a new string (C++20) (function template)
  • std::formatter<std::chrono::month> β€” formatting support for month (C++20) (class template specialization)

kisses and bye bestie πŸ’‹ β€” this page's footer says source/version http://cppreference.com, date 2024.06.10, and page std::chrono...rono::month)(3). periodt πŸ’…

πŸ“¦ where this page comes from