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_TUPLE_SLICE_HPP
0008 #define BOOST_HISTOGRAM_DETAIL_TUPLE_SLICE_HPP
0009 
0010 #include <boost/mp11/integer_sequence.hpp>
0011 #include <tuple>
0012 #include <type_traits>
0013 
0014 namespace boost {
0015 namespace histogram {
0016 namespace detail {
0017 
0018 template <std::size_t I, class T, std::size_t... K>
0019 decltype(auto) tuple_slice_impl(T&& t, mp11::index_sequence<K...>) {
0020   return std::forward_as_tuple(std::get<(I + K)>(std::forward<T>(t))...);
0021 }
0022 
0023 template <std::size_t I, std::size_t N, class Tuple>
0024 decltype(auto) tuple_slice(Tuple&& t) {
0025   constexpr auto S = std::tuple_size<std::decay_t<Tuple>>::value;
0026   static_assert(I + N <= S, "I, N must be a valid subset");
0027   return tuple_slice_impl<I>(std::forward<Tuple>(t), mp11::make_index_sequence<N>{});
0028 }
0029 
0030 } // namespace detail
0031 } // namespace histogram
0032 } // namespace boost
0033 
0034 #endif