Returns the absolute value of the duration d. Specifically, if d >= d.zero(), return d, otherwise return -d.
The function does not participate in the overload resolution unless std::numeric_limits<Rep>::is_signed is true.
[edit] Parameters [edit] Return valueAbsolute value of d.
[edit] Possible implementation [edit] Example#include <chrono> #include <iostream> int main() { using namespace std::chrono; static_assert(abs(-42s) == std::chrono::abs(42s)); std::cout << "abs(+3min) = " << abs(3min).count() << '\n' << "abs(-3min) = " << abs(-3min).count() << '\n'; }
Output:
abs(+3min) = 3 abs(-3min) = 3[edit] See also
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4