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
// SPDX-FileCopyrightText: Copyright (C) 2019 Tobias Hienzsch
3
4
#
ifndef
TETL_CHRONO_ABS_HPP
5
#
define
TETL_CHRONO_ABS_HPP
6
7
#
include
<
etl
/
_chrono
/
duration_cast
.
hpp
>
8
#
include
<
etl
/
_chrono
/
time_point_cast
.
hpp
>
9
#
include
<
etl
/
_limits
/
numeric_limits
.
hpp
>
10
#
include
<
etl
/
_type_traits
/
is_arithmetic
.
hpp
>
11
12
namespace
etl
::
chrono
{
13
14
/// Returns the absolute value of the duration d. Specifically, if d >= d.zero(),
15
/// return d, otherwise return -d. The function does not participate in the
16
/// overload resolution unless etl::numeric_limits<R>::is_signed is true.
17
/// \ingroup chrono
18
template
<
typename
R,
typename
P>
19
requires
(
numeric_limits
<R>::is_signed)
20
constexpr
auto
abs
(
duration
<R, P> d)
noexcept
(
is_arithmetic_v
<
R
>) ->
duration
<R, P>
21
{
22
return
d <
duration
<R, P>::zero() ?
duration
<R, P>::zero() - d : d;
23
}
24
25
}
// namespace etl::chrono
26
27
#
endif
// TETL_CHRONO_ABS_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:20
etl::chrono
Definition
abs.hpp:12
etl
Definition
adjacent_find.hpp:9
etl::chrono::duration
Class template etl::chrono::duration represents a time interval.
Definition
duration.hpp:32
etl::numeric_limits
Definition
numeric_limits.hpp:18
include
etl
_chrono
abs.hpp
Generated on Sun Sep 7 2025 19:15:09 for tetl by
1.9.8