std::chrono...day_indexed(3)
π std::chrono...day_indexed(3) π
okay so bestie, welcome to the C++ Standard Libary manual page for std::chrono::weekday_indexed β yes, the header really spells it Libary, and we are keeping that typo lore alive π
β¨
π NAME π
std::chrono::weekday_indexed β literally std::chrono::weekday_indexed. That's the whole name, that's the icon, no notes. π
πΈ Synopsis πΈ
Defined in header <chrono>
class weekday_indexed; (since C++20)
okay so picture this: weekday_indexed is the combo class. It combines a weekday β which represents a day of the week in the proleptic Gregorian calendar β with a small index n in the range [1, 5]. It represents the first, second, third, fourth, or fifth weekday of some month. ποΈβ¨
and yes, weekday_indexed is a TriviallyCopyable StandardLayoutType. Both of those exact named things. Periodt. π
π«Ά Member functions π«Ά
- constructor β constructs a
weekday_indexed(public member function) weekdayβ access the stored weekday (public member function)indexβ access the stored index (public member function)okβ checks if the weekday and index are both valid (public member function)
β¨ Nonmember functions β¨
operator==β compares twoweekday_indexedvalues(C++20)(function)operator<<β outputs aweekday_indexedinto a stream(C++20)(function template)
π Helper classes π
std::formatter<std::chrono::weekday_indexed>β formatting support forweekday_indexed(C++20)(class template specialization)std::hash<std::chrono::weekday_indexed>β hash support forstd::chrono::weekday_indexed(C++26)(class template specialization)
π§ Example π§
// Run this code β literally, go off bestie π
#include <chrono>
#include <iostream>
int main()
{
using namespace std::chrono;
constexpr weekday_indexed wi = Friday[2];
// Indexed weekday can be used at any place where chrono::day can be used:
constexpr year_month_weekday ymwd = 2021y / August / wi;
static_assert(ymwd == August / wi / 2021y &&
ymwd == wi / August / 2021y);
std::cout << ymwd << '\n';
constexpr year_month_day ymd{ymwd}; // a conversion
static_assert(ymd == 2021y / 8 / 13);
std::cout << ymd << '\n';
}
π Possible output π
2021/Aug/Fri[2]
2021-08-13
and that's the page, bestie π«Ά it came from http://cppreference.com, version/date 2024.06.10, and it's the std::chrono...day_indexed(3) page β slay, bye πβ¨
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms