mirror of
https://github.com/boostorg/beast.git
synced 2025-07-29 20:37:31 +02:00
Tidy up is_dynamic_buffer traits test
This commit is contained in:
@ -8,6 +8,7 @@ Version 44
|
||||
* Fix async return values in docs
|
||||
* Fix README websocket example
|
||||
* Add buffers_adapter regression test
|
||||
* Tidy up is_dynamic_buffer traits test
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
@ -198,81 +198,6 @@ public:
|
||||
type3::value && type4::value>;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
class is_dynamic_buffer
|
||||
{
|
||||
// size()
|
||||
template<class U, class R = std::is_convertible<decltype(
|
||||
std::declval<U const>().size()), std::size_t>>
|
||||
static R check1(int);
|
||||
template<class>
|
||||
static std::false_type check1(...);
|
||||
using type1 = decltype(check1<T>(0));
|
||||
|
||||
// max_size()
|
||||
template<class U, class R = std::is_convertible<decltype(
|
||||
std::declval<U const>().max_size()), std::size_t>>
|
||||
static R check2(int);
|
||||
template<class>
|
||||
static std::false_type check2(...);
|
||||
using type2 = decltype(check2<T>(0));
|
||||
|
||||
// capacity()
|
||||
template<class U, class R = std::is_convertible<decltype(
|
||||
std::declval<U const>().capacity()), std::size_t>>
|
||||
static R check3(int);
|
||||
template<class>
|
||||
static std::false_type check3(...);
|
||||
using type3 = decltype(check3<T>(0));
|
||||
|
||||
// data()
|
||||
template<class U, class R = std::integral_constant<
|
||||
bool, is_buffer_sequence<decltype(
|
||||
std::declval<U const>().data()),
|
||||
boost::asio::const_buffer>::type::value>>
|
||||
static R check4(int);
|
||||
template<class>
|
||||
static std::false_type check4(...);
|
||||
using type4 = decltype(check4<T>(0));
|
||||
|
||||
// prepare()
|
||||
template<class U, class R = std::integral_constant<
|
||||
bool, is_buffer_sequence<decltype(
|
||||
std::declval<U>().prepare(1)),
|
||||
boost::asio::mutable_buffer>::type::value>>
|
||||
static R check5(int);
|
||||
template<class>
|
||||
static std::false_type check5(...);
|
||||
using type5 = decltype(check5<T>(0));
|
||||
|
||||
// commit()
|
||||
template<class U, class R = decltype(
|
||||
std::declval<U>().commit(1), std::true_type{})>
|
||||
static R check6(int);
|
||||
template<class>
|
||||
static std::false_type check6(...);
|
||||
using type6 = decltype(check6<T>(0));
|
||||
|
||||
// consume
|
||||
template<class U, class R = decltype(
|
||||
std::declval<U>().consume(1), std::true_type{})>
|
||||
static R check7(int);
|
||||
template<class>
|
||||
static std::false_type check7(...);
|
||||
using type7 = decltype(check7<T>(0));
|
||||
|
||||
public:
|
||||
using type = std::integral_constant<bool,
|
||||
type1::value
|
||||
&& type2::value
|
||||
//&& type3::value // Networking TS
|
||||
&& type4::value
|
||||
&& type5::value
|
||||
&& type6::value
|
||||
&& type7::value
|
||||
>;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
template<class B1, class... Bn>
|
||||
|
@ -33,17 +33,6 @@ struct is_const_buffer_sequence :
|
||||
{
|
||||
};
|
||||
|
||||
/// Determine if `T` meets the requirements of @b DynamicBuffer.
|
||||
template<class T>
|
||||
#if BEAST_DOXYGEN
|
||||
struct is_dynamic_buffer : std::integral_constant<bool, ...>
|
||||
#else
|
||||
struct is_dynamic_buffer :
|
||||
detail::is_dynamic_buffer<T>::type
|
||||
#endif
|
||||
{
|
||||
};
|
||||
|
||||
/// Determine if `T` meets the requirements of @b MutableBufferSequence.
|
||||
template<class T>
|
||||
#if BEAST_DOXYGEN
|
||||
@ -56,6 +45,45 @@ struct is_mutable_buffer_sequence :
|
||||
{
|
||||
};
|
||||
|
||||
/// Determine if `T` meets the requirements of @b DynamicBuffer.
|
||||
#if BEAST_DOXYGEN
|
||||
template<class T>
|
||||
struct is_dynamic_buffer : std::integral_constant<bool, ...> {};
|
||||
#else
|
||||
template<class T, class = void>
|
||||
struct is_dynamic_buffer : std::false_type {};
|
||||
|
||||
template<class T>
|
||||
struct is_dynamic_buffer<T, beast::detail::void_t<
|
||||
decltype(
|
||||
// expressions
|
||||
std::declval<std::size_t&>() =
|
||||
std::declval<T const&>().size(),
|
||||
std::declval<std::size_t&>() =
|
||||
std::declval<T const&>().max_size(),
|
||||
#if 0
|
||||
// This check is skipped because boost::asio
|
||||
// types are not up to date with net-ts.
|
||||
std::declval<std::size_t&>() =
|
||||
std::declval<T const&>().capacity(),
|
||||
#endif
|
||||
std::declval<T&>().commit(std::declval<std::size_t>()),
|
||||
std::declval<T&>().consume(std::declval<std::size_t>()),
|
||||
(void)0)>> : std::integral_constant<bool,
|
||||
is_const_buffer_sequence<
|
||||
typename T::const_buffers_type>::value &&
|
||||
is_mutable_buffer_sequence<
|
||||
typename T::mutable_buffers_type>::value &&
|
||||
std::is_same<typename T::const_buffers_type,
|
||||
decltype(std::declval<T const&>().data())>::value &&
|
||||
std::is_same<typename T::mutable_buffers_type,
|
||||
decltype(std::declval<T&>().prepare(
|
||||
std::declval<std::size_t>()))>::value
|
||||
>
|
||||
{
|
||||
};
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//
|
||||
// Handler concepts
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <beast/core/type_traits.hpp>
|
||||
|
||||
#include <boost/asio/ip/tcp.hpp>
|
||||
#include <boost/asio/streambuf.hpp>
|
||||
|
||||
namespace beast {
|
||||
|
||||
@ -100,6 +101,8 @@ BOOST_STATIC_ASSERT(! is_const_buffer_sequence<T>::value);
|
||||
BOOST_STATIC_ASSERT(is_mutable_buffer_sequence<detail::MutableBufferSequence>::value);
|
||||
BOOST_STATIC_ASSERT(! is_mutable_buffer_sequence<T>::value);
|
||||
|
||||
BOOST_STATIC_ASSERT(is_dynamic_buffer<boost::asio::streambuf>::value);
|
||||
|
||||
} // (anonymous)
|
||||
|
||||
//
|
||||
|
Reference in New Issue
Block a user