tetl
0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
signbit.hpp
Go to the documentation of this file.
1
// SPDX-License-Identifier: BSL-1.0
2
3
#ifndef TETL_CMATH_SIGNBIT_HPP
4
#define TETL_CMATH_SIGNBIT_HPP
5
6
#include <
etl/_config/all.hpp
>
7
8
#include <
etl/_type_traits/is_constant_evaluated.hpp
>
9
10
namespace
etl
{
11
12
namespace
detail {
13
14
template
<
typename
T>
15
[[nodiscard]]
constexpr
auto
signbit_fallback(T
arg
)
noexcept
->
bool
16
{
17
return
arg
== T(-0.0) ||
arg
< T(0);
18
}
19
20
}
// namespace detail
21
31
[[nodiscard]]
constexpr
auto
signbit
(
float
arg
)
noexcept
->
bool
32
{
33
if
(
is_constant_evaluated
()) {
34
return
detail::signbit_fallback(
arg
);
35
}
36
#if __has_builtin(__builtin_signbit) and not defined(TETL_COMPILER_CLANG)
37
return
__builtin_signbit(
arg
);
38
#else
39
return
detail::signbit_fallback(
arg
);
40
#endif
41
}
42
52
[[nodiscard]]
constexpr
auto
signbit
(
double
arg
)
noexcept
->
bool
53
{
54
if
(
is_constant_evaluated
()) {
55
return
detail::signbit_fallback(
arg
);
56
}
57
#if __has_builtin(__builtin_signbit) and not defined(TETL_COMPILER_CLANG)
58
return
__builtin_signbit(
arg
);
59
#else
60
return
detail::signbit_fallback(
arg
);
61
#endif
62
}
63
73
[[nodiscard]]
constexpr
auto
signbit
(
long
double
arg
)
noexcept
->
bool
74
{
75
if
(
is_constant_evaluated
()) {
76
return
detail::signbit_fallback(
arg
);
77
}
78
#if __has_builtin(__builtin_signbit) and not defined(TETL_COMPILER_CLANG)
79
return
__builtin_signbit(
arg
);
80
#else
81
return
detail::signbit_fallback(
arg
);
82
#endif
83
}
84
85
}
// namespace etl
86
87
#endif
// TETL_CMATH_SIGNBIT_HPP
all.hpp
etl::arg
constexpr auto arg(complex< T > const &z) noexcept -> T
Definition
arg.hpp:15
is_constant_evaluated.hpp
etl
Definition
adjacent_find.hpp:8
etl::is_constant_evaluated
constexpr auto is_constant_evaluated() noexcept -> bool
Detects whether the function call occurs within a constant-evaluated context. Returns true if the eva...
Definition
is_constant_evaluated.hpp:16
etl::signbit
constexpr auto signbit(half arg) noexcept -> bool
Definition
half.hpp:74
include
etl
_cmath
signbit.hpp
Generated on Sat Mar 8 2025 16:19:59 for tetl by
1.14.0