diff --git a/CHANGELOG.md b/CHANGELOG.md index ee0c12ae..5ef2f3ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 -------------------------------------------------------------------------------- diff --git a/include/beast/core/detail/type_traits.hpp b/include/beast/core/detail/type_traits.hpp index 34f64e00..a992180a 100644 --- a/include/beast/core/detail/type_traits.hpp +++ b/include/beast/core/detail/type_traits.hpp @@ -198,81 +198,6 @@ public: type3::value && type4::value>; }; -template -class is_dynamic_buffer -{ - // size() - template().size()), std::size_t>> - static R check1(int); - template - static std::false_type check1(...); - using type1 = decltype(check1(0)); - - // max_size() - template().max_size()), std::size_t>> - static R check2(int); - template - static std::false_type check2(...); - using type2 = decltype(check2(0)); - - // capacity() - template().capacity()), std::size_t>> - static R check3(int); - template - static std::false_type check3(...); - using type3 = decltype(check3(0)); - - // data() - template().data()), - boost::asio::const_buffer>::type::value>> - static R check4(int); - template - static std::false_type check4(...); - using type4 = decltype(check4(0)); - - // prepare() - template().prepare(1)), - boost::asio::mutable_buffer>::type::value>> - static R check5(int); - template - static std::false_type check5(...); - using type5 = decltype(check5(0)); - - // commit() - template().commit(1), std::true_type{})> - static R check6(int); - template - static std::false_type check6(...); - using type6 = decltype(check6(0)); - - // consume - template().consume(1), std::true_type{})> - static R check7(int); - template - static std::false_type check7(...); - using type7 = decltype(check7(0)); - -public: - using type = std::integral_constant; -}; - //------------------------------------------------------------------------------ template diff --git a/include/beast/core/type_traits.hpp b/include/beast/core/type_traits.hpp index d41230bd..bf70d34f 100644 --- a/include/beast/core/type_traits.hpp +++ b/include/beast/core/type_traits.hpp @@ -33,17 +33,6 @@ struct is_const_buffer_sequence : { }; -/// Determine if `T` meets the requirements of @b DynamicBuffer. -template -#if BEAST_DOXYGEN -struct is_dynamic_buffer : std::integral_constant -#else -struct is_dynamic_buffer : - detail::is_dynamic_buffer::type -#endif -{ -}; - /// Determine if `T` meets the requirements of @b MutableBufferSequence. template #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 +struct is_dynamic_buffer : std::integral_constant {}; +#else +template +struct is_dynamic_buffer : std::false_type {}; + +template +struct is_dynamic_buffer() = + std::declval().size(), + std::declval() = + std::declval().max_size(), +#if 0 + // This check is skipped because boost::asio + // types are not up to date with net-ts. + std::declval() = + std::declval().capacity(), +#endif + std::declval().commit(std::declval()), + std::declval().consume(std::declval()), + (void)0)>> : std::integral_constant::value && + is_mutable_buffer_sequence< + typename T::mutable_buffers_type>::value && + std::is_same().data())>::value && + std::is_same().prepare( + std::declval()))>::value + > +{ +}; +#endif + //------------------------------------------------------------------------------ // // Handler concepts diff --git a/test/core/type_traits.cpp b/test/core/type_traits.cpp index a68215cd..d9ffba1f 100644 --- a/test/core/type_traits.cpp +++ b/test/core/type_traits.cpp @@ -9,6 +9,7 @@ #include #include +#include namespace beast { @@ -100,6 +101,8 @@ BOOST_STATIC_ASSERT(! is_const_buffer_sequence::value); BOOST_STATIC_ASSERT(is_mutable_buffer_sequence::value); BOOST_STATIC_ASSERT(! is_mutable_buffer_sequence::value); +BOOST_STATIC_ASSERT(is_dynamic_buffer::value); + } // (anonymous) //