std::chrono::month::operator unsigned
来自 cppreference.com
constexpr explicit operator unsigned() const noexcept; |
(自 C++20 起) | |
返回存储在 *this 中的月份值。
[编辑] 返回值
存储在 *this 中的月份值。
[编辑] 示例
运行此代码
#include <chrono> #include <iostream> int main() { constexpr std::chrono::month m{6}; constexpr unsigned p = static_cast<unsigned>(m); constexpr unsigned q = static_cast<unsigned>(std::chrono::September); std::cout << "The month is: " << p << '\n' << "September is: " << q << '\n'; }
输出
The month is: 6 September is: 9