isunordered.hpp 932 B

1234567891011121314151617181920212223242526272829303132333435
  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 <boost/math/ccmath/detail/config.hpp>
  8. #ifdef BOOST_MATH_NO_CCMATH
  9. #error "The header <boost/math/isunordered.hpp> can only be used in C++17 and later."
  10. #endif
  11. #include <boost/math/ccmath/isnan.hpp>
  12. namespace boost::math::ccmath {
  13. template <typename T>
  14. inline constexpr bool isunordered(const T x, const T y) noexcept
  15. {
  16. if(BOOST_MATH_IS_CONSTANT_EVALUATED(x))
  17. {
  18. return boost::math::ccmath::isnan(x) || boost::math::ccmath::isnan(y);
  19. }
  20. else
  21. {
  22. using std::isunordered;
  23. return isunordered(x, y);
  24. }
  25. }
  26. } // Namespaces
  27. #endif // BOOST_MATH_CCMATH_ISUNORDERED_HPP