isunordered.hpp 833 B

12345678910111213141516171819202122232425262728293031
  1. // (C) Copyright Matt Borland 2022.
  2. // Use, modification and distribution are subject to the
  3. // Boost Software License, Version 1.0. (See accompanying file
  4. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. #ifndef BOOST_MATH_CCMATH_ISUNORDERED_HPP
  6. #define BOOST_MATH_CCMATH_ISUNORDERED_HPP
  7. #include <cmath>
  8. #include <boost/math/tools/is_constant_evaluated.hpp>
  9. #include <boost/math/ccmath/isnan.hpp>
  10. namespace boost::math::ccmath {
  11. template <typename T>
  12. inline constexpr bool isunordered(const T x, const T y) noexcept
  13. {
  14. if(BOOST_MATH_IS_CONSTANT_EVALUATED(x))
  15. {
  16. return boost::math::ccmath::isnan(x) || boost::math::ccmath::isnan(y);
  17. }
  18. else
  19. {
  20. using std::isunordered;
  21. return isunordered(x, y);
  22. }
  23. }
  24. } // Namespaces
  25. #endif // BOOST_MATH_CCMATH_ISUNORDERED_HPP