Namespaces
Variants
Views
Actions

std::chrono::weekday_indexed::weekday_indexed

From cppreference.com
 
 
Utilities library
General utilities
Date and time
Function objects
Formatting library (C++20)
(C++11)
Relational operators (deprecated in C++20)
Integer comparison functions
(C++20)
Swap and type operations
(C++14)
(C++11)
(C++11)
(C++11)
(C++17)
Common vocabulary types
(C++11)
(C++17)
(C++17)
(C++17)
(C++17)

Elementary string conversions
(C++17)
(C++17)
 
Date and time utilities
(C++11)
(C++11)
Time of day
(C++20)



(C++20)(C++20)(C++20)(C++20)
Clocks
(C++20)
                                             
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
Calendars
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
Time zones
(C++20)
(C++20)
(C++20)
(C++20)
C-style date and time
 
 
weekday_indexed() = default;
(since C++20)
constexpr weekday_indexed(const std::chrono::weekday& wd, unsigned index) noexcept;
(since C++20)

Constructs a weekday_indexed.

1) Default constructor leaves both the std::chrono::weekday and the index value uninitialized.
2) Constructs a weekday_indexed storing the weekday wd and the index index. The values held are unspecified if !wd.ok() || index > 7.

[edit] Notes

A more convenient way to construct a weekday_indexed is with weekday's operator[], i.e., wd[index].

[edit] Example

#include <chrono>
#include <iostream>
using namespace std::chrono;
 
int main() {
  auto wdi = Tuesday[2]; // wdi is weekday_indexed representing the 2nd tuesday
  std::cout << year_month_day{ wdi / October / 2019y } ;
}

Output:

2019-10-08

[edit] See also

convenience syntax for constructing a weekday_indexed or weekday_last from this weekday
(public member function of std::chrono::weekday) [edit]