std::chrono::year(3)

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

std::chrono::year(3) πŸŽ€

okay bestie, welcome to the std::chrono::year(3) page from the C++ Standard Libary manual πŸ’– (yes, β€œLibary” is literally how the manual name is spelled in the header β€” iykyk). This is the whole cute little year-class situation, and we’re getting into every member, every operator, and every helper. no cap.

πŸ’– NAME πŸ’–

std::chrono::year β€” std::chrono::year

✨ Synopsis ✨

okay so she’s defined in header <chrono> and the class is literally this:

Defined in header <chrono>
class year;                 (since C++20)

The class year represents a year in the proleptic Gregorian calendar. Its range is [-32767, 32767]. That’s the whole range, bestie β€” no sneaky extra years hiding outside it.

year is a TriviallyCopyable StandardLayoutType. slay.

πŸŽ€ Member functions πŸŽ€

  • constructor β€” constructs a year (public member function)
  • operator++ β€” increments or decrements the year (public member function)
  • operator++(int) β€” increments or decrements the year (public member function)
  • operator-- β€” increments or decrements the year (public member function)
  • operator--(int) β€” increments or decrements the year (public member function)
  • operator+= β€” adds or subtracts a number of years from a year (public member function)
  • operator-= β€” adds or subtracts a number of years from a year (public member function)
  • operator+ β€” applies unary operators to year (public member function)
  • operator- β€” applies unary operators to year (public member function)
  • is_leap β€” determines if the year is a leap year (public member function)
  • operator int β€” retrieve the year value (public member function)
  • ok β€” checks if the stored year value is valid (public member function)
  • min [static] β€” returns the smallest possible year value (public static member function)
  • max [static] β€” returns the largest possible year (public static member function)

🌈 Non-member functions 🌈

  • operator==, operator<=> (C++20) β€” compares two year values (function)
  • operator+, operator- (C++20) β€” performs arithmetic on years (function)
  • operator<< (C++20) β€” outputs a year into a stream (function template)
  • from_stream (C++20) β€” parses a year from a stream according to the provided format (function template)

πŸ¦‹ Helper classes πŸ¦‹

  • std::formatter<std::chrono::year> (C++20) β€” formatting support for year (class template specialization)
  • std::hash<std::chrono::year> (C++26) β€” hash support for std::chrono::year (class template specialization)

🌸 Literals 🌸

Defined in inline namespace std::literals::chrono_literals

  • operator""y (C++20) β€” a std::chrono::year literal representing a particular year (function)

mwah πŸ’‹ before you go: source/version is http://cppreference.com, the date is 2024.06.10, and this icon is the std::chrono::year(3) page. periodt. πŸ’œ

πŸ“¦ where this page comes from