std::chrono::abs(std::chrono::duration)
Min standard notice:
Header: <chrono>
Returns the absolute value of the duration d. Specifically, if d >= d.zero(), return d, otherwise return -d.
# Declarations
template< class Rep, class Period >
constexpr std::chrono::duration<Rep, Period> abs( std::chrono::duration<Rep, Period> d );
(since C++17)
# Parameters
d: duration
# Return value
Absolute value of d.
# 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';
}