Tidy up read_size_helper and dynamic buffers

fix #376
This commit is contained in:
Vinnie Falco committed 2017-07-20 08:12:17 -07:00
1 parent 3543b4b913
commit 929174d4d8
15 files changed
+105 -46

No files matched your search

+28
View File
@@ -9,6 +9,8 @@
#define BEAST_TEST_BUFFER_TEST_HPP
#include <beast/core/type_traits.hpp>
#include <beast/core/detail/read_size_helper.hpp>
#include <beast/core/detail/type_traits.hpp>
#include <boost/asio/buffer.hpp>
#include <algorithm>
#include <type_traits>
@@ -83,6 +85,32 @@ size_rev_post(ConstBufferSequence const& buffers)
return n;
}
namespace has_read_size_helper
{
using beast::detail::read_size_helper;
template<class T, class = void>
struct trait : std::false_type {};
template<class T>
struct trait<T, decltype(
std::declval<std::size_t&>() =
read_size_helper(std::declval<T>(), 0),
(void)0)> : std::true_type
{
};
}
// Make sure read_size_helper works
template<class DynamicBuffer>
inline
void
check_read_size_helper()
{
static_assert(has_read_size_helper::trait<DynamicBuffer>::value,
"Missing read_size_helper for dynamic buffer");
}
} // test
} // beast