std::chrono::weekday_indexed::weekday_indexed
From cppreference.com
< cpp | chrono | weekday indexed
C++
Feature test macros (C++20)
Concepts library (C++20)
Metaprogramming library (C++11)
Ranges library (C++20)
Filesystem library (C++17)
Concurrency support library (C++11)
Execution control library (C++26)
Date and time library
(C++11)
(C++20)
(C++20)
(C++11)
(C++11)
(C++11)
(C++20)
(C++20)
(C++20)
(C++11)
(C++20)
(C++20)
(C++20)
(C++20)(C++20)
(C++20)(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)(C++20)
(C++20)
(C++20)
(C++20)
(C++20)(C++20)(C++20)(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
std::chrono::weekday_indexed
Member functions
weekday_indexed::weekday_indexed
Nonmember functions
Helper classes
weekday_indexed() = default;
(1)
(since C++20)
constexpr weekday_indexed( const std::chrono::weekday & wd, unsigned index ) noexcept;
(2)
(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
Run this code
#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日
[edit] See also
convenience syntax for constructing a weekday_indexed or weekday_last from this
(public member function of
weekday
(public member function of
std::chrono::weekday
) [edit]