1 // Copyright 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 7 #ifndef BOOST_HISTOGRAM_DETAIL_RELAXED_TUPLE_SIZE_HPP 8 #define BOOST_HISTOGRAM_DETAIL_RELAXED_TUPLE_SIZE_HPP 9 10 #include <type_traits> 11 12 namespace boost { 13 namespace histogram { 14 namespace detail { 15 16 using dynamic_size = std::integral_constant<std::size_t, static_cast<std::size_t>(-1)>; 17 18 // Returns static size of tuple or dynamic_size 19 template <class T> relaxed_tuple_size(const T &)20constexpr dynamic_size relaxed_tuple_size(const T&) noexcept { 21 return {}; 22 } 23 24 template <class... Ts> relaxed_tuple_size(const std::tuple<Ts...> &)25constexpr std::integral_constant<std::size_t, sizeof...(Ts)> relaxed_tuple_size( 26 const std::tuple<Ts...>&) noexcept { 27 return {}; 28 } 29 30 template <class T> 31 using relaxed_tuple_size_t = decltype(relaxed_tuple_size(std::declval<T>())); 32 33 } // namespace detail 34 } // namespace histogram 35 } // namespace boost 36 37 #endif 38