- chrono[meta header]
- std::chrono[meta namespace]
- class[meta id-type]
- cpp20[meta cpp]
namespace std::chrono {
class month_day_last;
}
month_day_last
は、未規定の年の、月の最終日を表すカレンダー表現のためクラスである。
2月の最終日が年によって異なることもあり、このクラスでは月の最終日が何日なのかは取得できない。そのためには、年情報を付加してyear_month_day_last
クラスに変換する必要がある。
このクラスは等値比較および大小比較ができ、EqualityComparableおよびLessThanComparableの要件を満たす。
このクラスは、トリビアルコピー可能で、かつスタンダードレイアウト型である。
名前 |
説明 |
対応バージョン |
(constructor) |
コンストラクタ |
C++20 |
month_day_last& operator=(const month_day_last&) = default; month_day_last& operator=(month_day_last&&) = default; |
代入演算子 |
C++20 |
名前 |
説明 |
対応バージョン |
month |
月要素を取得する |
C++20 |
名前 |
説明 |
対応バージョン |
ok |
値が範囲に収まっているか判定する |
C++20 |
名前 |
説明 |
対応バージョン |
operator/ |
カレンダー要素同士をつなぎ合わせる |
C++20 |
名前 |
説明 |
対応バージョン |
operator== |
等値比較を行う |
C++20 |
bool operator!=(const month_day_last&, const month_day_last&) noexcept; |
非等値比較を行う (== により使用可能) |
C++20 |
operator<=> |
三方比較を行う |
C++20 |
bool operator<(const month_day_last&, const month_day_last&) noexcept; |
左辺が右辺より小さいかを判定する (<=> により使用可能) |
C++20 |
bool operator<=(const month_day_last&, const month_day_last&) noexcept; |
左辺が右辺以下を判定する (<=> により使用可能) |
C++20 |
bool operator>(const month_day_last&, const month_day_last&) noexcept; |
左辺が右辺より大きいかを判定する (<=> により使用可能) |
C++20 |
bool operator>=(const month_day_last&, const month_day_last&) noexcept; |
左辺が右辺以上を判定する (<=> により使用可能) |
C++20 |
#include <iostream>
#include <chrono>
namespace chrono = std::chrono;
using namespace std::chrono_literals;
int main()
{
// すべて3月の最終日を表す
chrono::month_day_last date1 = chrono::last/3;
chrono::month_day_last date2 = chrono::March/chrono::last;
chrono::month_day_last date3{chrono::March};
chrono::month_day_last date4{chrono::month{3}};
std::cout << date1 << std::endl;
std::cout << date2 << std::endl;
std::cout << date3 << std::endl;
std::cout << date4 << std::endl;
}
- chrono::March[link month_constants.md]
- chrono::month[link month.md]
- chrono::last[link last_spec.md]
Mar/last
Mar/last
Mar/last
Mar/last