relaxed_equal.hpp 775 B

12345678910111213141516171819202122232425262728
  1. // Copyright 2015-2019 Hans Dembinski
  2. //
  3. // Distributed under the Boost Software License, Version 1.0.
  4. // (See accompanying file LICENSE_1_0.txt
  5. // or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. #ifndef BOOST_HISTOGRAM_DETAIL_RELAXED_EQUAL_HPP
  7. #define BOOST_HISTOGRAM_DETAIL_RELAXED_EQUAL_HPP
  8. #include <boost/histogram/detail/detect.hpp>
  9. #include <boost/histogram/detail/static_if.hpp>
  10. namespace boost {
  11. namespace histogram {
  12. namespace detail {
  13. template <class T>
  14. constexpr bool relaxed_equal(const T& a, const T& b) noexcept {
  15. return static_if<has_operator_equal<T>>(
  16. [](const auto& a, const auto& b) { return a == b; },
  17. [](const auto&, const auto&) { return true; }, a, b);
  18. }
  19. } // namespace detail
  20. } // namespace histogram
  21. } // namespace boost
  22. #endif