std::chrono...kday_indexed(3)
π NAME π
okay bestie, welcome to the C++ Standard Libary manual page for std::chrono...kday_indexed(3). The actual name is a whole mouthful:
std::chrono::month_weekday::month,std::chrono::month_weekday::weekday_indexedβstd::chrono::month_weekday::month,std::chrono::month_weekday::weekday_indexedβ yes, that's the same thing twice, and no, I didn't stutter π
β¨ Synopsis β¨
constexpr std::chrono::month month() const noexcept;
(1) (since C++20)
constexpr std::chrono::weekday_indexed weekday_indexed() const noexcept;
(2) (since C++20)
okay so these two are the accessors. They're both constexpr and noexcept, and both showed up in C++20, periodt. What do they do? They retrieve a copy of the month and weekday_indexed objects stored in *this. Like, not a reference, not a vibe, an actual copy, bestie. π«Ά
π Return value π
- A copy of the
std::chrono::monthobject stored in*thisβ it's giving "same month, fresh copy" πΈ - A copy of the
std::chrono::weekday_indexedobject stored in*thisβ sameweekday_indexedenergy, copied out π
π§ͺ Example π§ͺ
// Run this code
#include <chrono>
#include <iostream>
int main()
{
std::cout << std::boolalpha;
auto mwdi{std::chrono::March/std::chrono::Friday[1]}; // 1st Friday in a March
std::cout << (std::chrono::year_month_day{mwdi/2024} ==
std::chrono::year_month_day{std::chrono::March/1/2024})
<< ' ';
auto index = mwdi.weekday_indexed().index();
auto weekday = mwdi.weekday_indexed().weekday();
mwdi = {mwdi.month(), weekday[index + 4]}; // 5th Friday in a March
std::cout << (std::chrono::year_month_day{mwdi/2024} ==
std::chrono::year_month_day{std::chrono::March/29/2024})
<< '\n';
}
π» Output π»
true true
mwah π this page came from http://cppreference.com, dated 2024.06.10 β that's the source/version and date combo, and that's the whole footer vibe. Go forth and accessorize, bestie πβ¨
π¦ 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