A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://en.cppreference.com/w/cpp/ranges/../../cpp/../cpp/symbol_index/../chrono/duration/abs.html below:

std::chrono::abs(std::chrono::duration) - cppreference.com

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 value

Absolute 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