std::chrono::duration<Rep,Period>:: operator+ (unary) , std::chrono::duration<Rep,Period>:: operator- (unary)
From cppreference.net
C++
Date and time library
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
std::chrono::duration
| Member functions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Non-member functions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Helper classes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (1) | ||
|
constexpr
duration operator
+
(
)
const
;
|
(C++17 이전) | |
|
constexpr
std::
common_type_t
<
duration
>
operator
+
(
)
const
;
|
(C++17 이후) | |
| (2) | ||
|
constexpr
duration operator
-
(
)
const
;
|
(C++17 이전) | |
|
constexpr
std::
common_type_t
<
duration
>
operator
-
(
)
const
;
|
(C++17 이후) | |
durations에 대한 단항 플러스와 단항 마이너스를 구현합니다.
만약
rep_
가 duration 객체의 틱 수를 보유하는 멤버 변수이고,
D
가 반환 타입이라면,
1)
다음과 동일함:
return
D
(
*
this
)
;
.
2)
다음과 동일함
return
D
(
-
rep_
)
;
.
목차 |
매개변수
(없음)
반환값
1)
이 duration 객체의 복사본.
2)
이 duration 객체의 복사본으로, 틱(tick) 수가 부정(negated)된 것입니다.
예제
이 코드 실행
#include <chrono> #include <iostream> int main() { constexpr std::chrono::seconds s1(-052); constexpr std::chrono::seconds s2 = -s1; std::cout << "Negated " << s1 << " are " << s2 << '\n'; }
출력:
Negated -42s are 42s
참고 항목
|
틱 카운트를 증가 또는 감소시킴
(public member function) |
|
|
duration을 인자로 하는 산술 연산을 구현함
(function template) |