Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:38:12

0001 // Copyright 2015-2019 Hans Dembinski
0002 //
0003 // Distributed under the Boost Software License, Version 1.0.
0004 // (See accompanying file LICENSE_1_0.txt
0005 // or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 
0007 #ifndef BOOST_HISTOGRAM_DETAIL_RELAXED_EQUAL_HPP
0008 #define BOOST_HISTOGRAM_DETAIL_RELAXED_EQUAL_HPP
0009 
0010 #include <boost/histogram/detail/priority.hpp>
0011 #include <type_traits>
0012 
0013 namespace boost {
0014 namespace histogram {
0015 namespace detail {
0016 
0017 struct relaxed_equal {
0018   template <class T, class U>
0019   constexpr auto impl(const T& t, const U& u, priority<1>) const noexcept
0020       -> decltype(t == u) const {
0021     return t == u;
0022   }
0023 
0024   // consider T and U not equal, if there is no operator== defined for them
0025   template <class T, class U>
0026   constexpr bool impl(const T&, const U&, priority<0>) const noexcept {
0027     return false;
0028   }
0029 
0030   // consider two T equal if they are stateless
0031   template <class T>
0032   constexpr bool impl(const T&, const T&, priority<0>) const noexcept {
0033     return std::is_empty<T>::value;
0034   }
0035 
0036   template <class T, class U>
0037   constexpr bool operator()(const T& t, const U& u) const noexcept {
0038     return impl(t, u, priority<1>{});
0039   }
0040 };
0041 
0042 } // namespace detail
0043 } // namespace histogram
0044 } // namespace boost
0045 
0046 #endif