decorator constructor is constrained

This commit is contained in:
Vinnie Falco committed 2019-04-02 16:49:05 -07:00
1 parent a4974e18ba
commit 7c084509d6
4 files changed
+69 -1

No files matched your search

@@ -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))
{