std::chrono::month:: operator++, std::chrono::month:: operator--
From cppreference.net
|
constexpr
std::
chrono
::
month
&
operator
++
(
)
noexcept
;
|
(1) | (C++20 이후) |
|
constexpr
std::
chrono
::
month
operator
++
(
int
)
noexcept
;
|
(2) | (C++20 이후) |
|
constexpr
std::
chrono
::
month
&
operator
--
(
)
noexcept
;
|
(3) | (C++20 이후) |
|
constexpr
std::
chrono
::
month
operator
--
(
int
)
noexcept
;
|
(4) | (C++20 이후) |
월 값에 1을 더하거나 빼고, 결과를 모듈로 12로 환산하여
[
1
,
12
]
범위의 정수로 만듭니다.
1,2)
다음을 수행합니다
*
this
+
=
std::
chrono
::
months
{
1
}
;
.
3,4)
다음을 수행합니다
*
this
-
=
std::
chrono
::
months
{
1
}
;
.
목차 |
매개변수
(없음)
반환값
1,3)
수정 후 이
month
에 대한 참조입니다.
2,4)
수정 전에 생성된
month
의 복사본.
참고 사항
이러한 함수들 중 하나를 호출한 후에는, ok ( ) 가 항상 true 입니다.
예제
이 코드 실행
#include <cassert> #include <chrono> #include <iostream> int main() { std::chrono::month m{6}; ++m; assert(m == std::chrono::month(7)); --m; assert(m == std::chrono::month(6)); m = std::chrono::December; m++; // 1월로 순환 assert(m.ok()); std::cout << unsigned(m) << '\n'; m = std::chrono::January; m--; // 12월로 순환 assert(m.ok()); std::cout << unsigned(m) << '\n'; }
출력:
1 12
참고 항목
|
개월 수를 더하거나 뺌
(public member function) |
|
|
(C++20)
|
month
에 대한 산술 연산 수행
(function) |