Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:28:45

0001 //
0002 // detail/utility.hpp
0003 // ~~~~~~~~~~~~~~~~~~
0004 //
0005 // Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com)
0006 //
0007 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0008 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0009 //
0010 
0011 #ifndef BOOST_ASIO_DETAIL_UTILITY_HPP
0012 #define BOOST_ASIO_DETAIL_UTILITY_HPP
0013 
0014 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
0015 # pragma once
0016 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
0017 
0018 #include <boost/asio/detail/config.hpp>
0019 #include <utility>
0020 
0021 namespace boost {
0022 namespace asio {
0023 namespace detail {
0024 
0025 #if defined(BOOST_ASIO_HAS_STD_INDEX_SEQUENCE)
0026 
0027 using std::index_sequence;
0028 using std::index_sequence_for;
0029 using std::make_index_sequence;
0030 
0031 #else // defined(BOOST_ASIO_HAS_STD_INDEX_SEQUENCE)
0032 
0033 template <std::size_t...>
0034 struct index_sequence
0035 {
0036 };
0037 
0038 template <typename T, typename U>
0039 struct join_index_sequences;
0040 
0041 template <std::size_t... I, std::size_t... J>
0042 struct join_index_sequences<index_sequence<I...>, index_sequence<J...>>
0043 {
0044   using type = index_sequence<I..., J...>;
0045 };
0046 
0047 template <std::size_t First, std::size_t Last>
0048 struct index_pack :
0049   join_index_sequences<
0050     typename index_pack<First, First + (Last - First + 1) / 2 - 1>::type,
0051     typename index_pack<First + (Last - First + 1) / 2, Last>::type
0052   >
0053 {
0054 };
0055 
0056 template <std::size_t N>
0057 struct index_pack<N, N>
0058 {
0059   using type = index_sequence<N>;
0060 };
0061 
0062 template <std::size_t Begin, std::size_t End>
0063 struct index_range : index_pack<Begin, End - 1>
0064 {
0065 };
0066 
0067 template <std::size_t N>
0068 struct index_range<N, N>
0069 {
0070   using type = index_sequence<>;
0071 };
0072 
0073 template <typename... T>
0074 using index_sequence_for = typename index_range<0, sizeof...(T)>::type;
0075 
0076 template <std::size_t N>
0077 using make_index_sequence = typename index_range<0, N>::type;
0078 
0079 #endif // defined(BOOST_ASIO_HAS_STD_INDEX_SEQUENCE)
0080 
0081 } // namespace detail
0082 } // namespace asio
0083 } // namespace boost
0084 
0085 #endif // BOOST_ASIO_DETAIL_UTILITY_HPP