std::chrono::weekday::operator[] - cppreference.com (original) (raw)
Constructs a weekday_indexed from *this and
index. The result represents theindex-th weekday in some yet-to-be-specified month. Ifindexis not in the range[0,7]or if !ok() the values (an underlying weekday and an index) held in the result are unspecified.Constructs a weekday_last from *this. The result represents the last weekday in some yet-to-be-specified month.
[edit] Return value
[edit] Example
#include #include using namespace std::chrono; int main() { constexpr auto second_tuesday_in_October_2019 = year_month_day{Tuesday[2] / October / 2019y}; constexpr auto last_tuesday_in_October_2019 = year_month_day{Tuesday[last] / October / 2019y}; std::cout << second_tuesday_in_October_2019 << '\n' << last_tuesday_in_October_2019 << '\n'; }
Possible output: