get_lowest_layer is a type alias:

fix #941, fix #1016

`get_lowest_layer` is now a type alias for the
lowest layer instead of a struct with a nested type.

Actions required:

* Replace instances of `typename get_lowest_layer<T>::type`
  with `get_lowest_layer<T>`.
This commit is contained in:
Vinnie Falco
2018-02-21 14:49:44 -08:00
parent 66f0814cfd
commit eae74b1c89
7 changed files with 47 additions and 33 deletions

View File

@ -7,6 +7,16 @@ Version 158:
* DynamicBuffer input areas are not mutable * DynamicBuffer input areas are not mutable
* Tidy up some documentation * Tidy up some documentation
API Changes:
* get_lowest_layer is a type alias
Actions required:
* Replace instances of `typename get_lowest_layer<T>::type`
with `get_lowest_layer<T>`.
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
Version 157: Version 157:

View File

@ -160,7 +160,9 @@ to update to the latest Boost release.
Actions required: do not attempt to write to input areas of dynamic Actions required: do not attempt to write to input areas of dynamic
buffers. buffers.
* ([\issue 941]) `get_lowest_layer` is now a type alias.
Actions required: Replace instances of `typename get_lowest_layer<T>::type`
with `get_lowest_layer<T>`.
[heading Boost 1.66] [heading Boost 1.66]

View File

@ -111,8 +111,7 @@ public:
typename std::remove_reference<Stream>::type; typename std::remove_reference<Stream>::type;
/// The type of the lowest layer. /// The type of the lowest layer.
using lowest_layer_type = using lowest_layer_type = get_lowest_layer<next_layer_type>;
typename get_lowest_layer<next_layer_type>::type;
/** Move constructor. /** Move constructor.

View File

@ -255,6 +255,21 @@ max_all(U0 u0, U1 u1, UN... un)
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
template<class T, class = void>
struct get_lowest_layer_helper
{
using type = T;
};
template<class T>
struct get_lowest_layer_helper<T,
void_t<typename T::lowest_layer_type>>
{
using type = typename T::lowest_layer_type;
};
//------------------------------------------------------------------------------
// //
// buffer concepts // buffer concepts
// //

View File

@ -122,10 +122,10 @@ struct has_get_executor<T, beast::detail::void_t<decltype(
(void)0)>> : std::true_type {}; (void)0)>> : std::true_type {};
#endif #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` This will be a type alias for `T::lowest_layer_type`
if it exists, else `type` will be equal to `T`. if it exists, else it will be an alias for `T`.
@par Example @par Example
@ -136,7 +136,7 @@ struct has_get_executor<T, beast::detail::void_t<decltype(
struct stream_wrapper struct stream_wrapper
{ {
using next_layer_type = typename std::remove_reference<Stream>::type; using next_layer_type = typename std::remove_reference<Stream>::type;
using lowest_layer_type = typename get_lowest_layer<stream_type>::type; using lowest_layer_type = get_lowest_layer<stream_type>;
}; };
@endcode @endcode
@ -146,25 +146,15 @@ struct has_get_executor<T, beast::detail::void_t<decltype(
/// Alias for `std::true_type` if `T` wraps another stream /// Alias for `std::true_type` if `T` wraps another stream
template<class T> template<class T>
using is_stream_wrapper : std::integral_constant<bool, using is_stream_wrapper : std::integral_constant<bool,
! std::is_same<T, typename get_lowest_layer<T>::type>::value> {}; ! std::is_same<T, get_lowest_layer<T>>::value> {};
@endcode @endcode
*/ */
#if BOOST_BEAST_DOXYGEN #if BOOST_BEAST_DOXYGEN
template<class T> template<class T>
struct get_lowest_layer; struct get_lowest_layer;
#else #else
template<class T, class = void>
struct get_lowest_layer
{
using type = T;
};
template<class T> template<class T>
struct get_lowest_layer<T, detail::void_t< using get_lowest_layer = typename detail::get_lowest_layer_helper<T>::type;
typename T::lowest_layer_type>>
{
using type = typename T::lowest_layer_type;
};
#endif #endif
/** Determine if `T` meets the requirements of @b AsyncReadStream. /** Determine if `T` meets the requirements of @b AsyncReadStream.

View File

@ -225,8 +225,7 @@ public:
typename std::remove_reference<NextLayer>::type; typename std::remove_reference<NextLayer>::type;
/// The type of the lowest layer. /// The type of the lowest layer.
using lowest_layer_type = using lowest_layer_type = get_lowest_layer<next_layer_type>;
typename get_lowest_layer<next_layer_type>::type;
/// The type of the executor associated with the object. /// The type of the executor associated with the object.
using executor_type = typename next_layer_type::executor_type; using executor_type = typename next_layer_type::executor_type;

View File

@ -71,8 +71,7 @@ struct F3
using next_layer_type = using next_layer_type =
typename std::remove_reference<F>::type; typename std::remove_reference<F>::type;
using lowest_layer_type = typename using lowest_layer_type = get_lowest_layer<next_layer_type>;
get_lowest_layer<next_layer_type>::type;
}; };
template<class F> template<class F>
@ -81,18 +80,18 @@ struct F4
using next_layer_type = using next_layer_type =
typename std::remove_reference<F>::type; typename std::remove_reference<F>::type;
using lowest_layer_type = typename using lowest_layer_type =
get_lowest_layer<next_layer_type>::type; get_lowest_layer<next_layer_type>;
}; };
BOOST_STATIC_ASSERT(std::is_same<get_lowest_layer<F1>::type, F1>::value); BOOST_STATIC_ASSERT(std::is_same<get_lowest_layer<F1>, F1>::value);
BOOST_STATIC_ASSERT(std::is_same<get_lowest_layer<F2>::type, F2>::value); BOOST_STATIC_ASSERT(std::is_same<get_lowest_layer<F2>, F2>::value);
BOOST_STATIC_ASSERT(std::is_same<get_lowest_layer<F3<F1>>::type, F1>::value); BOOST_STATIC_ASSERT(std::is_same<get_lowest_layer<F3<F1>>, F1>::value);
BOOST_STATIC_ASSERT(std::is_same<get_lowest_layer<F3<F2>>::type, F2>::value); BOOST_STATIC_ASSERT(std::is_same<get_lowest_layer<F3<F2>>, F2>::value);
BOOST_STATIC_ASSERT(std::is_same<get_lowest_layer<F4<F1>>::type, F1>::value); BOOST_STATIC_ASSERT(std::is_same<get_lowest_layer<F4<F1>>, F1>::value);
BOOST_STATIC_ASSERT(std::is_same<get_lowest_layer<F4<F2>>::type, F2>::value); BOOST_STATIC_ASSERT(std::is_same<get_lowest_layer<F4<F2>>, F2>::value);
BOOST_STATIC_ASSERT(std::is_same<get_lowest_layer<F4<F3<F1>>>::type, F1>::value); BOOST_STATIC_ASSERT(std::is_same<get_lowest_layer<F4<F3<F1>>>, F1>::value);
BOOST_STATIC_ASSERT(std::is_same<get_lowest_layer<F4<F3<F2>>>::type, F2>::value); BOOST_STATIC_ASSERT(std::is_same<get_lowest_layer<F4<F3<F2>>>, F2>::value);
// //
// min_all, max_all // min_all, max_all