std::chrono::weekday::operator[]
提供: cppreference.com
constexpr std::chrono::weekday_indexed operator[](unsigned index) const noexcept; |
(1) | (C++20以上) |
constexpr std::chrono::weekday_last operator[](std::chrono::last_spec) const noexcept; |
(2) | (C++20以上) |
1)
*this
と index
から weekday_indexed
を構築します。 結果は、まだ指定されていないいずれかの月の、 index
回目の *this
曜日を表します。 index
が [1, 5] の範囲でない場合、または !ok() の場合、結果に格納される値は未規定です。2)
*this
から weekday_last
を構築します。 結果は、まだ指定されていないいずれかの月の、最後の *this
曜日を表します。[編集] 戻り値
1) std::chrono::weekday_indexed(*this, index)
2) std::chrono::weekday_last(*this)
[編集] 例
Run this code
#include <chrono> #include <iostream> using namespace std::chrono; int main() { // 2019年10月の第2火曜日。 std::cout << year_month_day{ Tuesday[2] / October / 2019y } << '\n' // 2019年10月の最後の火曜日。 << year_month_day{ Tuesday[last] / October / 2019y } << '\n'; }
出力:
2019-10-08 2019-10-29