名前空間
変種
操作

std::chrono::weekday::operator[]

提供: cppreference.com
< cpp‎ | chrono‎ | weekday
 
 
ユーティリティライブラリ
汎用ユーティリティ
日付と時間
関数オブジェクト
書式化ライブラリ(C++20)
(C++11)
関係演算子 (C++20で非推奨)
整数比較関数
(C++20)
スワップと型操作
(C++14)
(C++11)
(C++11)
(C++11)
(C++17)
一般的な語彙の型
(C++11)
(C++17)
(C++17)
(C++17)
(C++17)

初等文字列変換
(C++17)
(C++17)
 
日付と時間のユーティリティ
(C++11)
(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 スタイルの日付と時間
 
 
constexpr std::chrono::weekday_indexed operator[](unsigned index)constnoexcept;
(1) (C++20以上)
constexpr std::chrono::weekday_last operator[](std::chrono::last_spec)constnoexcept;
(2) (C++20以上)
1)*thisindex から 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)

[編集]

#include <chrono>#include <iostream>usingnamespace 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
close