tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
isinf.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_CMATH_ISINF_HPP
5#define TETL_CMATH_ISINF_HPP
6
7#include <etl/_config/all.hpp>
8
9#include <etl/_concepts/integral.hpp>
10#include <etl/_limits/numeric_limits.hpp>
11#include <etl/_type_traits/is_constant_evaluated.hpp>
12
13namespace etl {
14
15namespace detail {
16
17inline constexpr struct isinf {
18 template <typename Float>
19 [[nodiscard]] constexpr auto operator()(Float arg) const -> bool
20 {
21#if __has_builtin(__builtin_isinf)
22 return __builtin_isinf(arg) != 0;
23#else
24 return arg == etl::numeric_limits<Float>::infinity();
25#endif
26 }
27} isinf;
28
29} // namespace detail
30
31/// Determines if the given floating point number arg is a positive or negative infinity.
32/// \details https://en.cppreference.com/w/cpp/numeric/math/isinf
33/// \ingroup cmath
34[[nodiscard]] constexpr auto isinf(float arg) -> bool
35{
36 return etl::detail::isinf(arg);
37}
38
39/// \ingroup cmath
40[[nodiscard]] constexpr auto isinf(double arg) -> bool
41{
42 return etl::detail::isinf(arg);
43}
44
45/// \ingroup cmath
46[[nodiscard]] constexpr auto isinf(long double arg) -> bool
47{
48 return etl::detail::isinf(arg);
49}
50
51/// \ingroup cmath
52template <etl::integral Int>
53[[nodiscard]] constexpr auto isinf(Int arg) -> bool
54{
55 return etl::detail::isinf(static_cast<double>(arg));
56}
57
58} // namespace etl
59
60#endif // TETL_CMATH_ISINF_HPP
constexpr auto isinf(double arg) -> bool
Definition isinf.hpp:40
constexpr auto isinf(Int arg) -> bool
Definition isinf.hpp:53
constexpr auto isinf(float arg) -> bool
Determines if the given floating point number arg is a positive or negative infinity.
Definition isinf.hpp:34
constexpr auto isinf(long double arg) -> bool
Definition isinf.hpp:46
Definition adjacent_find.hpp:9