tetl
0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
abs.hpp
Go to the documentation of this file.
1
// SPDX-License-Identifier: BSL-1.0
2
3
#ifndef TETL_CHRONO_ABS_HPP
4
#define TETL_CHRONO_ABS_HPP
5
6
#include <
etl/_chrono/duration_cast.hpp
>
7
#include <
etl/_chrono/time_point_cast.hpp
>
8
#include <
etl/_limits/numeric_limits.hpp
>
9
#include <
etl/_type_traits/is_arithmetic.hpp
>
10
11
namespace
etl::chrono
{
12
17
template
<
typename
R,
typename
P>
18
requires
(
numeric_limits<R>::is_signed
)
19
constexpr
auto
abs
(
duration<R, P>
d)
noexcept
(
is_arithmetic_v<R>
) ->
duration<R, P>
20
{
21
return
d < duration<R, P>::zero() ?
duration<R, P>::zero
() - d : d;
22
}
23
24
}
// namespace etl::chrono
25
26
#endif
// TETL_CHRONO_ABS_HPP
duration_cast.hpp
etl::chrono::abs
constexpr auto abs(duration< R, P > d) noexcept(is_arithmetic_v< R >) -> duration< R, P >
Returns the absolute value of the duration d. Specifically, if d >= d.zero(), return d,...
Definition
abs.hpp:19
is_arithmetic.hpp
etl::chrono
Definition
abs.hpp:11
etl::is_arithmetic_v
constexpr bool is_arithmetic_v
Definition
is_arithmetic.hpp:21
numeric_limits.hpp
etl::chrono::duration
Class template etl::chrono::duration represents a time interval.
Definition
duration.hpp:31
etl::chrono::duration::zero
static constexpr auto zero() noexcept -> duration
Returns a zero-length duration.
Definition
duration.hpp:100
etl::numeric_limits::is_signed
static constexpr bool is_signed
Definition
numeric_limits.hpp:28
time_point_cast.hpp
include
etl
_chrono
abs.hpp
Generated on Sat Mar 8 2025 16:19:59 for tetl by
1.14.0