共用方式為


weekday_indexed 類別

結合一個工作日,代表公曆中的星期幾,以及代表月份工作日的 [1, 5] 範圍中的索引(1、2、3 等)。

語法

class weekday_indexed; // C++20

備註

weekday_indexed 是一種簡單可複製且標準版面配置類別類型。

成員

名稱 描述
建構函式 weekday_indexed使用指定的工作日與值建構 。
ok 檢查工作日值是否有效。
weekday 取得工作日值。

非成員

名稱 描述
operator== 判斷兩個 weekday_indexed 實例是否相等。
operator<< weekday_indexed將 輸出至指定的數據流。

需求

標頭:<chrono>自 C++20 起

命名空間std::chrono

編譯程序選項: /std:c++latest

建構函式

weekday_indexed使用值與索引建構初始化weekday的 。

constexpr weekday_indexed(const chrono::weekday& wd, unsigned index) noexcept; // C++20

參數

wd
所建立 weekday_indexed 類別的工作日值。

index
工作日登陸的月份工作日。 它位於範圍 [1, 5]。 例如,2 表示工作日會落在當月的第二周。

範例:建立 weekday_indexed

// compile using: /std:c++latest
#include <iostream>
#include <chrono>

using namespace std::chrono;

int main()
{
   constexpr auto wdi = weekday_indexed{Monday, 1};
   constexpr auto wdi2 = Monday[1];

    std::cout << wdi << ", " << wdi2;
    return 0;
}
Mon[1], Mon[1]

ok

檢查儲存在此 中的 weekday_indexed 值是否在有效範圍內。

constexpr bool ok() const noexcept;

傳回值

true 如果周工作日值在有效範圍內,則為 。 否則為 false

weekday

取得工作日值。

constexpr chrono::weekday weekday() const noexcept;

傳回值

工作日值。

範例

// compile using: /std:c++latest
#include <iostream>
#include <chrono>

int main()
{
    constexpr auto wdi = weekday_indexed{ Monday, 1 };
	std::cout << wdi << "\n";

    return 0;
}
Mon[1]

另請參閱

weekday 類別
weekday_last 類別
<chrono>
標頭檔參考