std::chrono::year::operator++, std::chrono::year::operator--
From cppreference.com
| constexpr std::chrono::year& operator++() noexcept; |
(1) | (C++20以降) |
| constexpr std::chrono::year operator++( int ) noexcept; |
(2) | (C++20以降) |
| constexpr std::chrono::year& operator--() noexcept; |
(3) | (C++20以降) |
| constexpr std::chrono::year operator--( int ) noexcept; |
(4) | (C++20以降) |
年(year)の値に1を加算または減算します。
1,2) *this += std::chrono::years{1}; を実行します。
3,4) *this -= std::chrono::years{1}; を実行します。
目次 |
[編集] パラメータ
(なし)
[編集] 戻り値
1,3) 変更後のこの
yearへの参照。2,4) 変更前の
yearのコピー。[編集] 注釈
結果が範囲 [-32767, 32767] を超える場合、実際に格納される値は未定義です。
[編集] 例
このコードを実行
#include <chrono> #include <iostream> int main() { std::cout << std::boolalpha; std::chrono::year y{2020}; std::cout << (++y == std::chrono::year(2021)) << ' '; std::cout << (--y == std::chrono::year(2020)) << '\n'; using namespace std::literals::chrono_literals; y = 32767y; y++; //← unspecified, see ↑ Notes ↑ std::cout << static_cast<int>(y) << '\n'; }
実行結果の例
true true -32768
[編集] 関連項目
yearに年数を加算または減算します(public member function) | |
| (C++20) |
year に対して演算を実行する(関数) |