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