mirror of
https://github.com/boostorg/beast.git
synced 2025-07-30 04:47:29 +02:00
decorator constructor is constrained
This commit is contained in:
@ -1,3 +1,9 @@
|
||||
Version 245:
|
||||
|
||||
* decorator constructor is constrained
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
Version 244:
|
||||
|
||||
* Tidy up declval in some traits
|
||||
|
@ -25,6 +25,27 @@ namespace beast {
|
||||
namespace websocket {
|
||||
namespace detail {
|
||||
|
||||
// VFALCO NOTE: When this is two traits, one for
|
||||
// request and one for response,
|
||||
// Visual Studio 2015 fails.
|
||||
|
||||
template<class T, class U, class = void>
|
||||
struct can_invoke_with : std::false_type
|
||||
{
|
||||
};
|
||||
|
||||
template<class T, class U>
|
||||
struct can_invoke_with<T, U, boost::void_t<decltype(
|
||||
std::declval<T&>()(std::declval<U&>()))>>
|
||||
: std::true_type
|
||||
{
|
||||
};
|
||||
|
||||
template<class T>
|
||||
using is_decorator = std::integral_constant<bool,
|
||||
can_invoke_with<T, request_type>::value ||
|
||||
can_invoke_with<T, response_type>::value>;
|
||||
|
||||
class decorator
|
||||
{
|
||||
friend class decorator_test;
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <boost/beast/websocket/detail/decorator.hpp>
|
||||
#include <boost/beast/core/role.hpp>
|
||||
#include <chrono>
|
||||
#include <type_traits>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
@ -65,7 +66,13 @@ struct stream_base
|
||||
@param f An invocable function object. Ownership of
|
||||
the function object is transferred by decay-copy.
|
||||
*/
|
||||
template<class Decorator>
|
||||
template<class Decorator
|
||||
#ifndef BOOST_BEAST_DOXYGEN
|
||||
,class = typename std::enable_if<
|
||||
detail::is_decorator<
|
||||
Decorator>::value>::type
|
||||
#endif
|
||||
>
|
||||
decorator(Decorator&& f)
|
||||
: d_(std::forward<Decorator>(f))
|
||||
{
|
||||
|
@ -19,6 +19,40 @@ namespace websocket {
|
||||
class stream_base_test : public unit_test::suite
|
||||
{
|
||||
public:
|
||||
struct T1
|
||||
{
|
||||
void operator()(request_type&);
|
||||
};
|
||||
|
||||
struct T2
|
||||
{
|
||||
void operator()(response_type&);
|
||||
};
|
||||
|
||||
struct T3
|
||||
{
|
||||
void operator()(request_type&);
|
||||
void operator()(response_type&);
|
||||
};
|
||||
|
||||
struct T4
|
||||
{
|
||||
template<class T>
|
||||
void operator()(T&);
|
||||
};
|
||||
|
||||
struct T5
|
||||
{
|
||||
void operator()();
|
||||
};
|
||||
|
||||
BOOST_STATIC_ASSERT(detail::is_decorator<T1>::value);
|
||||
BOOST_STATIC_ASSERT(detail::is_decorator<T2>::value);
|
||||
BOOST_STATIC_ASSERT(detail::is_decorator<T3>::value);
|
||||
BOOST_STATIC_ASSERT(detail::is_decorator<T4>::value);
|
||||
BOOST_STATIC_ASSERT(! detail::is_decorator<T5>::value);
|
||||
BOOST_STATIC_ASSERT(! detail::is_decorator<int>::value);
|
||||
|
||||
void
|
||||
testJavadoc()
|
||||
{
|
||||
|
Reference in New Issue
Block a user