std::chrono::year:: operator+=, std::chrono::year:: operator-=
From cppreference.net
C++
Date and time library
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
std::chrono::year
| Member functions | ||||
|
year::operator+=
year::operator-=
|
||||
| Nonmember functions | ||||
| Helper classes | ||||
|
(C++26)
|
|
constexpr
std::
chrono
::
year
&
operator
+
=
(
const
std::
chrono
::
years
&
y
)
noexcept
;
|
(1) | (C++20부터) |
|
constexpr
std::
chrono
::
year
&
operator
-
=
(
const
std::
chrono
::
years
&
y
)
noexcept
;
|
(2) | (C++20부터) |
연도 값에 y. count ( ) 년을 더하거나 뺍니다.
1)
다음과 동일함
*
this
=
*
this
+
y
;
.
2)
다음과 동일함
*
this
=
*
this
-
y
;
.
목차 |
반환값
수정 후 이
year
에 대한 참조입니다.
참고 사항
결과가 범위
[
-
32767
,
32767
]
를 벗어날 경우, 실제 저장되는 값은 지정되지 않습니다.
예제
이 코드 실행
#include <chrono> #include <iostream> int main() { using namespace std::literals::chrono_literals; std::cout << std::boolalpha; std::chrono::year y{2020}; y += std::chrono::years(12); std::cout << (y == 2032y) << ' '; y -= std::chrono::years(33); std::cout << (y == 1999y) << '\n'; }
출력:
true true
참고 항목
|
연도를 증가 또는 감소시킴
(public member function) |
|
|
(C++20)
|
year
에 대한 산술 연산 수행
(function) |