std::chrono::year:: operator++, std::chrono::year:: operator--
From cppreference.net
|
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以降) |
年値に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++; //← 未定義、上記の注記を参照 std::cout << static_cast<int>(y) << '\n'; }
出力例:
true true -32768
関連項目
year
に年数を加算または減算する
(公開メンバ関数) |
|
|
(C++20)
|
year
に対する算術演算を実行する
(関数) |