diff --git a/CHANGELOG.md b/CHANGELOG.md index 8fecef41..0f3f2863 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,16 @@ Version 158: * DynamicBuffer input areas are not mutable * Tidy up some documentation +API Changes: + +* get_lowest_layer is a type alias + +Actions required: + +* Replace instances of `typename get_lowest_layer::type` + with `get_lowest_layer`. + + -------------------------------------------------------------------------------- Version 157: diff --git a/doc/qbk/09_releases.qbk b/doc/qbk/09_releases.qbk index 0b45efc2..b2150040 100644 --- a/doc/qbk/09_releases.qbk +++ b/doc/qbk/09_releases.qbk @@ -160,7 +160,9 @@ to update to the latest Boost release. Actions required: do not attempt to write to input areas of dynamic buffers. - +* ([\issue 941]) `get_lowest_layer` is now a type alias. + Actions required: Replace instances of `typename get_lowest_layer::type` + with `get_lowest_layer`. [heading Boost 1.66] diff --git a/include/boost/beast/core/buffered_read_stream.hpp b/include/boost/beast/core/buffered_read_stream.hpp index e683a409..a546d3eb 100644 --- a/include/boost/beast/core/buffered_read_stream.hpp +++ b/include/boost/beast/core/buffered_read_stream.hpp @@ -111,8 +111,7 @@ public: typename std::remove_reference::type; /// The type of the lowest layer. - using lowest_layer_type = - typename get_lowest_layer::type; + using lowest_layer_type = get_lowest_layer; /** Move constructor. diff --git a/include/boost/beast/core/detail/type_traits.hpp b/include/boost/beast/core/detail/type_traits.hpp index f07697c9..d4233a95 100644 --- a/include/boost/beast/core/detail/type_traits.hpp +++ b/include/boost/beast/core/detail/type_traits.hpp @@ -255,6 +255,21 @@ max_all(U0 u0, U1 u1, UN... un) //------------------------------------------------------------------------------ +template +struct get_lowest_layer_helper +{ + using type = T; +}; + +template +struct get_lowest_layer_helper> +{ + using type = typename T::lowest_layer_type; +}; + +//------------------------------------------------------------------------------ + // // buffer concepts // diff --git a/include/boost/beast/core/type_traits.hpp b/include/boost/beast/core/type_traits.hpp index 3c52d60f..f5e466a7 100644 --- a/include/boost/beast/core/type_traits.hpp +++ b/include/boost/beast/core/type_traits.hpp @@ -122,10 +122,10 @@ struct has_get_executor> : std::true_type {}; #endif -/** Returns `T::lowest_layer_type` if it exists, else `T` +/** Alias for `T::lowest_layer_type` if it exists, else `T` - This will contain a nested `type` equal to `T::lowest_layer_type` - if it exists, else `type` will be equal to `T`. + This will be a type alias for `T::lowest_layer_type` + if it exists, else it will be an alias for `T`. @par Example @@ -136,7 +136,7 @@ struct has_get_executor::type; - using lowest_layer_type = typename get_lowest_layer::type; + using lowest_layer_type = get_lowest_layer; }; @endcode @@ -146,25 +146,15 @@ struct has_get_executor using is_stream_wrapper : std::integral_constant::type>::value> {}; + ! std::is_same>::value> {}; @endcode */ #if BOOST_BEAST_DOXYGEN template struct get_lowest_layer; #else -template -struct get_lowest_layer -{ - using type = T; -}; - template -struct get_lowest_layer> -{ - using type = typename T::lowest_layer_type; -}; +using get_lowest_layer = typename detail::get_lowest_layer_helper::type; #endif /** Determine if `T` meets the requirements of @b AsyncReadStream. diff --git a/include/boost/beast/websocket/stream.hpp b/include/boost/beast/websocket/stream.hpp index 95260385..9a522cbf 100644 --- a/include/boost/beast/websocket/stream.hpp +++ b/include/boost/beast/websocket/stream.hpp @@ -225,8 +225,7 @@ public: typename std::remove_reference::type; /// The type of the lowest layer. - using lowest_layer_type = - typename get_lowest_layer::type; + using lowest_layer_type = get_lowest_layer; /// The type of the executor associated with the object. using executor_type = typename next_layer_type::executor_type; diff --git a/test/beast/core/type_traits.cpp b/test/beast/core/type_traits.cpp index 9411b90e..45ceb23e 100644 --- a/test/beast/core/type_traits.cpp +++ b/test/beast/core/type_traits.cpp @@ -71,8 +71,7 @@ struct F3 using next_layer_type = typename std::remove_reference::type; - using lowest_layer_type = typename - get_lowest_layer::type; + using lowest_layer_type = get_lowest_layer; }; template @@ -81,18 +80,18 @@ struct F4 using next_layer_type = typename std::remove_reference::type; - using lowest_layer_type = typename - get_lowest_layer::type; + using lowest_layer_type = + get_lowest_layer; }; -BOOST_STATIC_ASSERT(std::is_same::type, F1>::value); -BOOST_STATIC_ASSERT(std::is_same::type, F2>::value); -BOOST_STATIC_ASSERT(std::is_same>::type, F1>::value); -BOOST_STATIC_ASSERT(std::is_same>::type, F2>::value); -BOOST_STATIC_ASSERT(std::is_same>::type, F1>::value); -BOOST_STATIC_ASSERT(std::is_same>::type, F2>::value); -BOOST_STATIC_ASSERT(std::is_same>>::type, F1>::value); -BOOST_STATIC_ASSERT(std::is_same>>::type, F2>::value); +BOOST_STATIC_ASSERT(std::is_same, F1>::value); +BOOST_STATIC_ASSERT(std::is_same, F2>::value); +BOOST_STATIC_ASSERT(std::is_same>, F1>::value); +BOOST_STATIC_ASSERT(std::is_same>, F2>::value); +BOOST_STATIC_ASSERT(std::is_same>, F1>::value); +BOOST_STATIC_ASSERT(std::is_same>, F2>::value); +BOOST_STATIC_ASSERT(std::is_same>>, F1>::value); +BOOST_STATIC_ASSERT(std::is_same>>, F2>::value); // // min_all, max_all