class
std::chrono::year(C++20)
namespace std::chrono {
class year;
}
概要
year
は、年単体の値を表すカレンダー表現のためクラスである。
値の範囲として[-32767, 32767]
を扱う。
このクラスは等値比較および大小比較ができ、EqualityComparableおよびLessThanComparableの要件を満たす。
このクラスは、トリビアルコピー可能で、かつスタンダードレイアウト型である。
備考
- このクラスは時間間隔を表す型ではない。年の時間間隔は
years
である
メンバ関数
構築/コピー/破棄
名前 |
説明 |
対応バージョン |
(constructor) |
コンストラクタ |
C++20 |
year& operator=(const year&) = default; year& operator=(year&&) = default; |
代入演算子 |
C++20 |
算術演算
うるう年
名前 |
説明 |
対応バージョン |
is_leap |
うるう年かを判定する |
C++20 |
変換
値の範囲
名前 |
説明 |
対応バージョン |
ok |
値が範囲[min(), max()] に収まっているか判定する |
C++20 |
静的メンバ関数
値の範囲
名前 |
説明 |
対応バージョン |
min |
扱える最小値 |
C++20 |
max |
扱える最大値 |
C++20 |
非メンバ関数
算術演算
カレンダー構文演算子
名前 |
説明 |
対応バージョン |
operator/ |
カレンダー要素同士をつなぎ合わせる |
C++20 |
比較演算
名前 |
説明 |
対応バージョン |
operator== |
等値比較を行う |
C++20 |
bool operator!=(const year&, const year&) noexcept; |
非等値比較を行う (== により使用可能) |
C++20 |
operator<=> |
三方比較を行う |
C++20 |
bool operator<(const year&, const year&) noexcept; |
左辺が右辺より小さいかを判定する (<=> により使用可能) |
C++20 |
bool operator<=(const year&, const year&) noexcept; |
左辺が右辺以下を判定する (<=> により使用可能) |
C++20 |
bool operator>(const year&, const year&) noexcept; |
左辺が右辺より大きいかを判定する (<=> により使用可能) |
C++20 |
bool operator>=(const year&, const year&) noexcept; |
左辺が右辺以上を判定する (<=> により使用可能) |
C++20 |
入出力
リテラル
名前 |
説明 |
対応バージョン |
y |
年リテラル |
C++20 |
文字列フォーマットサポート
ハッシュサポート
名前 |
説明 |
対応バージョン |
template <class T> struct hash; |
hash クラスの先行宣言 |
C++26 |
template<> struct hash<chrono::year>; |
hash クラスのyear に対する特殊化 |
C++26 |
例
出力
2023
2020/Mar/01
バージョン
言語
処理系
参照