Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Copyright 2015-2018 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_COMMON_TYPE_HPP
0008 #define BOOST_HISTOGRAM_DETAIL_COMMON_TYPE_HPP
0009 
0010 #include <boost/histogram/detail/detect.hpp>
0011 #include <boost/histogram/fwd.hpp>
0012 #include <boost/mp11/list.hpp>
0013 #include <boost/mp11/utility.hpp>
0014 #include <tuple>
0015 #include <type_traits>
0016 
0017 namespace boost {
0018 namespace histogram {
0019 namespace detail {
0020 // clang-format off
0021 template <class T, class U>
0022 using common_axes = mp11::mp_cond<
0023   is_tuple<T>, T,
0024   is_tuple<U>, U,
0025   is_sequence_of_axis<T>, T,
0026   is_sequence_of_axis<U>, U,
0027   std::true_type, T
0028 >;
0029 // clang-format on
0030 
0031 // Non-PODs rank highest, then floats, than integers; types with more capacity are higher
0032 template <class Storage>
0033 constexpr std::size_t type_rank() {
0034   using T = typename Storage::value_type;
0035   return !std::is_arithmetic<T>::value * 10000 + std::is_floating_point<T>::value * 100 +
0036          10 * sizeof(T) + 2 * is_array_like<Storage>::value +
0037          is_vector_like<Storage>::value;
0038   ;
0039 }
0040 
0041 template <class T, class U>
0042 using common_storage = mp11::mp_if_c<(type_rank<T>() >= type_rank<U>()), T, U>;
0043 } // namespace detail
0044 } // namespace histogram
0045 } // namespace boost
0046 
0047 #endif