isgreater.hpp 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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_ISGREATER_HPP
  6. #define BOOST_MATH_CCMATH_ISGREATER_HPP
  7. #include <boost/math/ccmath/detail/config.hpp>
  8. #ifdef BOOST_MATH_NO_CCMATH
  9. #error "The header <boost/math/isgreater.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 T1, typename T2 = T1>
  14. inline constexpr bool isgreater(T1 x, T2 y) noexcept
  15. {
  16. if (BOOST_MATH_IS_CONSTANT_EVALUATED(x))
  17. {
  18. if (boost::math::ccmath::isnan(x) || boost::math::ccmath::isnan(y))
  19. {
  20. return false;
  21. }
  22. else
  23. {
  24. return x > y;
  25. }
  26. }
  27. else
  28. {
  29. using std::isgreater;
  30. return isgreater(x, y);
  31. }
  32. }
  33. } // Namespaces
  34. #endif // BOOST_MATH_CCMATH_ISGREATER_HPP