isless.hpp 933 B

123456789101112131415161718192021222324252627282930313233343536373839
  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_ISLESS_HPP
  6. #define BOOST_MATH_CCMATH_ISLESS_HPP
  7. #include <cmath>
  8. #include <limits>
  9. #include <boost/math/tools/is_constant_evaluated.hpp>
  10. #include <boost/math/ccmath/isnan.hpp>
  11. namespace boost::math::ccmath {
  12. template <typename T1, typename T2 = T1>
  13. inline constexpr bool isless(T1 x, T2 y) noexcept
  14. {
  15. if (BOOST_MATH_IS_CONSTANT_EVALUATED(x))
  16. {
  17. if (boost::math::ccmath::isnan(x) || boost::math::ccmath::isnan(y))
  18. {
  19. return false;
  20. }
  21. else
  22. {
  23. return x < y;
  24. }
  25. }
  26. else
  27. {
  28. using std::isless;
  29. return isless(x, y);
  30. }
  31. }
  32. } // Namespaces
  33. #endif // BOOST_MATH_CCMATH_ISLESS_HPP