- chrono[meta header]
- std::chrono[meta namespace]
- year[meta class]
- function[meta id-type]
- cpp20[meta cpp]
constexpr explicit operator int() const noexcept; // (1) C++20yearオブジェクトをint型に明示的に変換する。
- (1) : メンバ変数として保持している
int型としての年の値を返す
#include <cassert>
#include <chrono>
namespace chrono = std::chrono;
int main()
{
chrono::year y{2020};
auto value = static_cast<int>(y);
assert(value == 2020);
}- C++20
- Clang: 8.0
- GCC: (9.2時点で実装なし)
- Visual C++: (2019 Update 3時点で実装なし)