| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | //====================================================================================================================== | ||
| 2 | /* | ||
| 3 | POLYFLOAT - Extended precision floating points | ||
| 4 | Copyright : POLYFLOAT Contributors & Maintainers | ||
| 5 | SPDX-License-Identifier: BSL-1.0 | ||
| 6 | */ | ||
| 7 | //====================================================================================================================== | ||
| 8 | #pragma once | ||
| 9 | |||
| 10 | #include <polyfloat/details/callable.hpp> | ||
| 11 | #include <polyfloat/types/concepts.hpp> | ||
| 12 | #include <polyfloat/types/traits.hpp> | ||
| 13 | #include <type_traits> | ||
| 14 | |||
| 15 | namespace plf | ||
| 16 | { | ||
| 17 | |||
| 18 | template<typename Options> | ||
| 19 | struct is_not_equal_t | ||
| 20 | : plf::callable<is_not_equal_t, eve::is_not_equal_t, Options, raw_option, pedantic_option, numeric_option> | ||
| 21 | { | ||
| 22 | template<concepts::polyfloat_like Z1, concepts::polyfloat_like Z2> | ||
| 23 | 14027 | POLYFLOAT_ABI constexpr eve::as_logical_t<as_polyfloat_like_t<Z1, Z2>> operator()(Z1 z1, Z2 z2) const noexcept | |
| 24 | { | ||
| 25 | 14027 | return POLYFLOAT_CALL(z1, z2); | |
| 26 | } | ||
| 27 | |||
| 28 | 14017 | POLYFLOAT_CALLABLE_OBJECT(is_not_equal_t, is_not_equal_); | |
| 29 | }; | ||
| 30 | //====================================================================================================================== | ||
| 31 | //! @addtogroup core | ||
| 32 | //! @{ | ||
| 33 | //! @var is_not_equal | ||
| 34 | //! @brief return the is_not_equal value. | ||
| 35 | //! | ||
| 36 | //! @groupheader{Header file} | ||
| 37 | //! | ||
| 38 | //! @code | ||
| 39 | //! #include <polyfloat/core.hpp> | ||
| 40 | //! @endcode | ||
| 41 | //! | ||
| 42 | //! @groupheader{Callable Signatures} | ||
| 43 | //! | ||
| 44 | //! @code | ||
| 45 | //! namespace polyfloat | ||
| 46 | //! { | ||
| 47 | //! template<polyfloat::concepts::polyfloat_like T1, polyfloat_like Z2> constexpr auto is_not_equal(T1 z1, T2 z2) noexcept; //1 | ||
| 48 | //! template<polyfloat::concepts::polyfloat_like T1, polyfloat_like Z2> constexpr auto is_not_equal[numeric](T1 z1, T2 z2) noexcept; //2 | ||
| 49 | //! } | ||
| 50 | //! @endcode | ||
| 51 | //! | ||
| 52 | //! **Parameters** | ||
| 53 | //! | ||
| 54 | //! * `z1`, `z2` : Values to process. | ||
| 55 | //! | ||
| 56 | //! **Return value** | ||
| 57 | //! | ||
| 58 | //! 1. Returns true is `z1` is not_equal to `z2`. | ||
| 59 | //! 2. consider nan values as not_equal | ||
| 60 | //! | ||
| 61 | //! @groupheader{Example} | ||
| 62 | //! | ||
| 63 | //! @godbolt_todo{doc/core/is_not_equal.cpp} | ||
| 64 | //====================================================================================================================== | ||
| 65 | |||
| 66 | inline constexpr auto is_not_equal = eve::functor<is_not_equal_t>; | ||
| 67 | //====================================================================================================================== | ||
| 68 | //! @} | ||
| 69 | //====================================================================================================================== | ||
| 70 | } | ||
| 71 | |||
| 72 | namespace plf::_ | ||
| 73 | { | ||
| 74 | template<typename Z1, typename Z2, eve::callable_options O> | ||
| 75 | 14017 | constexpr auto is_not_equal_(POLYFLOAT_DELAY(), O const&, Z1 const& z1, Z2 const& z2) noexcept | |
| 76 | { | ||
| 77 | 14017 | auto neq = z1 != z2; | |
| 78 | if constexpr (O::contains(numeric)) return neq || (is_nan(z1) && is_nan(z2)); | ||
| 79 | 14017 | else return neq; | |
| 80 | } | ||
| 81 | } | ||
| 82 |