std::chrono:: operator+, std::chrono:: operator- (std::chrono::year_month_day)
|
헤더에 정의됨
<chrono>
|
||
|
constexpr
std::
chrono
::
year_month_day
operator
+
(
const
std::
chrono
::
year_month_day
&
ymd,
const
std::
chrono
::
months
&
dm
|
(C++20부터) | |
|
constexpr
std::
chrono
::
year_month_day
operator
+
(
const
std::
chrono
::
months
&
dm,
const
std::
chrono
::
year_month_day
&
ymd
|
(C++20부터) | |
|
constexpr
std::
chrono
::
year_month_day
operator
+
(
const
std::
chrono
::
year_month_day
&
ymd,
const
std::
chrono
::
years
&
dy
|
(C++20부터) | |
|
constexpr
std::
chrono
::
year_month_day
operator
+
(
const
std::
chrono
::
years
&
dy,
const
std::
chrono
::
year_month_day
&
ymd
|
(C++20부터) | |
|
constexpr
std::
chrono
::
year_month_day
operator
-
(
const
std::
chrono
::
year_month_day
&
ymd,
const
std::
chrono
::
months
&
dm
|
(C++20부터) | |
|
constexpr
std::
chrono
::
year_month_day
operator
-
(
const
std::
chrono
::
year_month_day
&
ymd,
const
std::
chrono
::
years
&
dy
|
(C++20부터) | |
std::chrono::years
와
std::chrono::months
모두로 변환 가능한 지속 시간의 경우,
호출이 모호해질 수 있는 상황에서는
years
오버로드
(3,4,6)
가 우선적으로 선택됩니다.
참고 사항
ymd.
ok
(
)
가
true
라 하더라도, 결과로 생성된
year_month_day
가 유효하지 않은 날짜를 나타낼 수 있습니다. 특히
ymd.
day
(
)
가 29, 30, 또는 31일 경우에 그러합니다.
예제
#include <chrono> #include <iostream> int main() { std::cout << std::boolalpha; auto ymd{std::chrono::day(1)/std::chrono::July/2021}; ymd = ymd + std::chrono::months(4); std::cout << (ymd.month() == std::chrono::November) << ' ' << (ymd.year() == std::chrono::year(2021)) << ' '; ymd = ymd - std::chrono::years(10); std::cout << (ymd.month() == std::chrono::month(11)) << ' ' << (ymd.year() == std::chrono::year(2011)) << '\n'; }
출력:
true true true true