std::chrono::operator+, std::chrono::operator- (std::chrono::year)
提供: cppreference.com
<tbody>
</tbody>
constexpr std::chrono::year operator+(const std::chrono::year& y, const std::chrono::years& ys) noexcept; |
(1) | (C++20以上) |
constexpr std::chrono::year operator+(const std::chrono::years& ys, const std::chrono::year& y) noexcept; |
(2) | (C++20以上) |
constexpr std::chrono::year operator-(const std::chrono::year& y, const std::chrono::years& ys) noexcept; |
(3) | (C++20以上) |
constexpr std::chrono::years operator-(const std::chrono::year& y1, const std::chrono::year& y2) noexcept; |
(4) | (C++20以上) |
1-2)
y に ys.count() 年を加算します。3)
y から ys.count() 年を減算します。4)
y1 と y2 の差の年数を返します。戻り値
1-2)
std::chrono::year(int(y) + ys.count())3)
std::chrono::year(int(y) - ys.count())4)
std::chrono::years(int(y1) - int(y2))ノート
(1-3) について、結果の年の値が [-32767, 32767] の範囲外の場合、実際に格納される値は未規定です。
2つの year の値の減算の結果は、 std::chrono::years 型の duration です。 この duration の単位は平均的なグレゴリオ暦の1年の長さを表し、結果の duration は引数が表す特定の年の日数とは無関係です。 例えば、 2018y - 2017y の結果は std::chrono::years(1) であり、これは 365 日ではなく 365.2425 日です。
例
| This section is incomplete Reason: no example |
関連項目
| 月をインクリメントまたはデクリメントします ( std::chrono::monthのパブリックメンバ関数)
| |
| 月数を加算または減算します ( std::chrono::monthのパブリックメンバ関数)
|