mirror of
https://github.com/boostorg/beast.git
synced 2025-08-02 06:15:24 +02:00
Tidy up DynamicBuffer requirements
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
* Add HTTPS example
|
* Add HTTPS example
|
||||||
* Add Secure WebSocket example
|
* Add Secure WebSocket example
|
||||||
* Fix message_v1 constructor
|
* Fix message_v1 constructor
|
||||||
|
* Tidy up DynamicBuffer requirements
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@@ -88,50 +88,76 @@ public:
|
|||||||
template<class T>
|
template<class T>
|
||||||
class is_DynamicBuffer
|
class is_DynamicBuffer
|
||||||
{
|
{
|
||||||
template<class U, class R = std::integral_constant<
|
// size()
|
||||||
bool, is_BufferSequence<decltype(
|
template<class U, class R = std::is_convertible<decltype(
|
||||||
std::declval<U>().prepare(1)),
|
std::declval<U const>().size()), std::size_t>>
|
||||||
boost::asio::mutable_buffer>::type::value>>
|
|
||||||
static R check1(int);
|
static R check1(int);
|
||||||
template<class>
|
template<class>
|
||||||
static std::false_type check1(...);
|
static std::false_type check1(...);
|
||||||
using type1 = decltype(check1<T>(0));
|
using type1 = decltype(check1<T>(0));
|
||||||
|
|
||||||
template<class U, class R = std::integral_constant<
|
// max_size()
|
||||||
bool, is_BufferSequence<decltype(
|
template<class U, class R = std::is_convertible<decltype(
|
||||||
std::declval<U>().data()),
|
std::declval<U const>().max_size()), std::size_t>>
|
||||||
boost::asio::const_buffer>::type::value>>
|
|
||||||
static R check2(int);
|
static R check2(int);
|
||||||
template<class>
|
template<class>
|
||||||
static std::false_type check2(...);
|
static std::false_type check2(...);
|
||||||
using type2 = decltype(check2<T>(0));
|
using type2 = decltype(check2<T>(0));
|
||||||
|
|
||||||
template<class U, class R = decltype(
|
// capacity()
|
||||||
std::declval<U>().commit(1), std::true_type{})>
|
template<class U, class R = std::is_convertible<decltype(
|
||||||
|
std::declval<U const>().capacity()), std::size_t>>
|
||||||
static R check3(int);
|
static R check3(int);
|
||||||
template<class>
|
template<class>
|
||||||
static std::false_type check3(...);
|
static std::false_type check3(...);
|
||||||
using type3 = decltype(check3<T>(0));
|
using type3 = decltype(check3<T>(0));
|
||||||
|
|
||||||
template<class U, class R = decltype(
|
// data()
|
||||||
std::declval<U>().consume(1), std::true_type{})>
|
template<class U, class R = std::integral_constant<
|
||||||
|
bool, is_BufferSequence<decltype(
|
||||||
|
std::declval<U const>().data()),
|
||||||
|
boost::asio::const_buffer>::type::value>>
|
||||||
static R check4(int);
|
static R check4(int);
|
||||||
template<class>
|
template<class>
|
||||||
static std::false_type check4(...);
|
static std::false_type check4(...);
|
||||||
using type4 = decltype(check4<T>(0));
|
using type4 = decltype(check4<T>(0));
|
||||||
|
|
||||||
template<class U, class R = std::is_same<decltype(
|
// prepare()
|
||||||
std::declval<U>().size()), std::size_t>>
|
template<class U, class R = std::integral_constant<
|
||||||
|
bool, is_BufferSequence<decltype(
|
||||||
|
std::declval<U>().prepare(1)),
|
||||||
|
boost::asio::mutable_buffer>::type::value>>
|
||||||
static R check5(int);
|
static R check5(int);
|
||||||
template<class>
|
template<class>
|
||||||
static std::false_type check5(...);
|
static std::false_type check5(...);
|
||||||
using type5 = decltype(check5<T>(0));
|
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:
|
public:
|
||||||
using type = std::integral_constant<bool,
|
using type = std::integral_constant<bool,
|
||||||
type1::value && type2::value &&
|
type1::value
|
||||||
type3::value && type4::value &&
|
&& type2::value
|
||||||
type5::value>;
|
//&& type3::value // Networking TS
|
||||||
|
&& type4::value
|
||||||
|
&& type5::value
|
||||||
|
&& type6::value
|
||||||
|
&& type7::value
|
||||||
|
>;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // detail
|
} // detail
|
||||||
|
@@ -7,3 +7,10 @@
|
|||||||
|
|
||||||
// Test that header file is self-contained.
|
// Test that header file is self-contained.
|
||||||
#include <beast/core/streambuf.hpp>
|
#include <beast/core/streambuf.hpp>
|
||||||
|
|
||||||
|
#include <beast/core/buffer_concepts.hpp>
|
||||||
|
namespace beast {
|
||||||
|
|
||||||
|
static_assert(is_DynamicBuffer<streambuf>::value, "");
|
||||||
|
|
||||||
|
} // beast
|
||||||
|
Reference in New Issue
Block a user