From c0e5d1bd7656b7b4cff47d5efac27ac7bfac683b Mon Sep 17 00:00:00 2001 From: Damian Jarek Date: Thu, 22 Nov 2018 22:39:05 +0100 Subject: [PATCH] Use mp11::integer_sequence Close #1317 Signed-off-by: Damian Jarek --- CHANGELOG.md | 6 + .../beast/core/detail/integer_sequence.hpp | 143 ------------------ include/boost/beast/http/impl/message.ipp | 6 +- include/boost/beast/http/message.hpp | 10 +- .../beast/websocket/detail/stream_base.hpp | 1 - 5 files changed, 14 insertions(+), 152 deletions(-) delete mode 100644 include/boost/beast/core/detail/integer_sequence.hpp diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c812eb9..d11b62a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +Version 192: + +* Use mp11::integer_sequence + +-------------------------------------------------------------------------------- + Version 191: * Add bind_front_handler diff --git a/include/boost/beast/core/detail/integer_sequence.hpp b/include/boost/beast/core/detail/integer_sequence.hpp deleted file mode 100644 index 71664229..00000000 --- a/include/boost/beast/core/detail/integer_sequence.hpp +++ /dev/null @@ -1,143 +0,0 @@ -// -// Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// Official repository: https://github.com/boostorg/beast -// - -#ifndef BOOST_BEAST_DETAIL_INTEGER_SEQUENCE_HPP -#define BOOST_BEAST_DETAIL_INTEGER_SEQUENCE_HPP - -#include -#include -#include -#include - -namespace boost { -namespace beast { -namespace detail { - -template -struct integer_sequence -{ - using value_type = T; - BOOST_STATIC_ASSERT(std::is_integral::value); - - static std::size_t constexpr static_size = sizeof...(Ints); - - static std::size_t constexpr size() - { - return sizeof...(Ints); - } -}; - -template -using index_sequence = integer_sequence; - -// This workaround is needed for broken sizeof... -template -struct sizeof_workaround -{ - static std::size_t constexpr size = sizeof... (Args); -}; - -#ifdef BOOST_MSVC - -// This implementation compiles on real MSVC and clang but not gcc - -template -struct make_integer_sequence_unchecked; - -template -struct make_integer_sequence_unchecked< - T, N, integer_sequence> -{ - using type = typename make_integer_sequence_unchecked< - T, N-1, integer_sequence>::type; -}; - -template -struct make_integer_sequence_unchecked< - T, 0, integer_sequence> -{ - using type = integer_sequence; -}; - -template -struct make_integer_sequence_checked -{ - BOOST_STATIC_ASSERT(std::is_integral::value); - BOOST_STATIC_ASSERT(N >= 0); - - using type = typename make_integer_sequence_unchecked< - T, N, integer_sequence>::type; -}; - -template -using make_integer_sequence = - typename make_integer_sequence_checked::type; - -template -using make_index_sequence = make_integer_sequence; - -template -using index_sequence_for = - make_index_sequence::size>; - -#else - -// This implementation compiles on gcc but not MSVC - -template -struct index_tuple -{ - using next = index_tuple; - -}; - -template -struct build_index_tuple -{ - using type = typename build_index_tuple::type::next; -}; - -template<> -struct build_index_tuple<0> -{ - using type = index_tuple<>; -}; - -template::type -> -struct integer_sequence_helper; - -template -struct integer_sequence_helper> -{ - BOOST_STATIC_ASSERT(std::is_integral::value); - BOOST_STATIC_ASSERT(N >= 0); - - using type = integer_sequence (Ints)...>; -}; - -template -using make_integer_sequence = - typename integer_sequence_helper::type; - -template -using make_index_sequence = make_integer_sequence; - -template -using index_sequence_for = - make_index_sequence::size>; - -#endif - -} // detail -} // beast -} // boost - -#endif diff --git a/include/boost/beast/http/impl/message.ipp b/include/boost/beast/http/impl/message.ipp index a2a10402..d4ad5773 100644 --- a/include/boost/beast/http/impl/message.ipp +++ b/include/boost/beast/http/impl/message.ipp @@ -295,7 +295,7 @@ message(std::piecewise_construct_t, std::tuple body_args) : message(std::piecewise_construct, body_args, - beast::detail::make_index_sequence< + mp11::make_index_sequence< sizeof...(BodyArgs)>{}) { } @@ -309,9 +309,9 @@ message(std::piecewise_construct_t, : message(std::piecewise_construct, body_args, fields_args, - beast::detail::make_index_sequence< + mp11::make_index_sequence< sizeof...(BodyArgs)>{}, - beast::detail::make_index_sequence< + mp11::make_index_sequence< sizeof...(FieldsArgs)>{}) { } diff --git a/include/boost/beast/http/message.hpp b/include/boost/beast/http/message.hpp index bd85d160..45098814 100644 --- a/include/boost/beast/http/message.hpp +++ b/include/boost/beast/http/message.hpp @@ -16,8 +16,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -804,7 +804,7 @@ struct message @li @ref chunked would return `true` @li @ref result returns @ref status::no_content - + @li @ref result returns @ref status::not_modified @li @ref result returns any informational status class (100 to 199) @@ -901,7 +901,7 @@ private: message( std::piecewise_construct_t, std::tuple& body_args, - beast::detail::index_sequence) + mp11::index_sequence) : boost::empty_value< typename Body::value_type>(boost::empty_init_t(), std::forward( @@ -919,8 +919,8 @@ private: std::piecewise_construct_t, std::tuple& body_args, std::tuple& fields_args, - beast::detail::index_sequence, - beast::detail::index_sequence) + mp11::index_sequence, + mp11::index_sequence) : header_type(std::forward( std::get(fields_args))...) , boost::empty_value< diff --git a/include/boost/beast/websocket/detail/stream_base.hpp b/include/boost/beast/websocket/detail/stream_base.hpp index 4da5747e..f54e56d4 100644 --- a/include/boost/beast/websocket/detail/stream_base.hpp +++ b/include/boost/beast/websocket/detail/stream_base.hpp @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include