std::chrono::weekday_indexed
來自 cppreference.com
定義於標頭檔案 <chrono> |
||
class weekday_indexed; |
(C++20 起) | |
類 weekday_indexed
將一個 weekday(表示 純格里高利曆 中的某一天)與一個範圍在 [
1,
5]
的小索引 n
組合在一起。它表示某個月份的第一、第二、第三、第四或第五個工作日。
weekday_indexed
是一個 可平凡複製的 標準佈局型別。
目錄 |
[編輯] 成員函式
構造一個 weekday_indexed (public 成員函式) | |
訪問儲存的 weekday (public 成員函式) | |
訪問儲存的索引 (public 成員函式) | |
檢查工作日和索引是否都有效 (public 成員函式) |
[編輯] 非成員函式
(C++20) |
比較兩個 weekday_indexed 值(函式) |
(C++20) |
將 weekday_indexed 輸出到流中(函式模板) |
[編輯] 輔助類
weekday_indexed 的格式化支援(類模板特化) | |
對 std::chrono::weekday_indexed 的雜湊支援 (類模板特化) |
[編輯] 示例
執行此程式碼
#include <chrono> #include <iostream> int main() { using namespace std::chrono; constexpr weekday_indexed wi = Friday[2]; // Indexed weekday can be used at any place where chrono::day can be used: constexpr year_month_weekday ymwd = 2021y / August / wi; static_assert(ymwd == August / wi / 2021y && ymwd == wi / August / 2021y); std::cout << ymwd << '\n'; constexpr year_month_day ymd{ymwd}; // a conversion static_assert(ymd == 2021y / 8 / 13); std::cout << ymd << '\n'; }
可能的輸出
2021/Aug/Fri[2] 2021-08-13