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
에 연도를 더하거나 뺍니다
(public member function) |
|
|
(C++20)
|
year
에 대한 산술 연산을 수행합니다
(function) |