std::chrono...kday_indexed(3)
π¦ NAME π¦
Bestie, you're on the std::chrono...kday_indexed(3) page, and the manual name is C++ Standard Libary β yes, that spelling, we are not fixing it, periodt. The icon herself is:
std::chrono::weekday_indexed::weekday_indexed β std::chrono::weekday_indexed::weekday_indexed
β¨ Synopsis β¨
It constructs a weekday_indexed. There are two constructors, both (since C++20):
weekday_indexed() = default;β constructor (1) (since C++20).constexpr weekday_indexed( const std::chrono::weekday& wd, unsigned index ) noexcept;β constructor (2) (since C++20).
The details, because we stay factual while being iconic:
- The default constructor leaves both the
std::chrono::weekdayand the index value uninitialized. Not me leaving things blank on purpose π. - Constructs a
weekday_indexedstoring the weekdaywdand the indexindex. The values held are unspecified if!wd.ok() || index > 7.
π¨ Vibe check: if !wd.ok() || index > 7, the values held are unspecified. That is the caveat, no cap β do not act like it's cute to ignore.
πΈ Notes πΈ
A more convenient way to construct a weekday_indexed is with weekday's operator[], i.e., wd[index]. That's the lowkey main character shortcut, iykyk. π
π Example π
// Run this code β literally, go run it:
#include <chrono>
#include <iostream>
using namespace std::chrono;
int main()
{
constexpr auto third_friday = weekday_indexed(Friday, 3); // uses constructor (2)
static_assert(third_friday == Friday[3]);
weekday_indexed wdi = Tuesday[2]; // represents the 2nd Tuesday
std::cout << year_month_day{ wdi / October / 2019y } << '\n';
}
π Possible output π
2019-10-08
π See also π
operator[]β convenience syntax for constructing aweekday_indexedorweekday_lastfrom thisweekday(public member function ofstd::chrono::weekday).
And that's the whole page, bestie π«Ά. Signing off from http://cppreference.com, dated 2024.06.10, with std::chrono...kday_indexed(3) energy. Mwah πβ¨
π¦ 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