From 62878255fb0b8a8e1864694e6eac1da65619e837 Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Sun, 3 Mar 2019 07:33:34 -0800 Subject: [PATCH] Workaround for msvc-14.0 --- .../beast/websocket/detail/decorator.hpp | 57 +++++++++++-------- test/beast/websocket/_detail_decorator.cpp | 14 ++--- 2 files changed, 38 insertions(+), 33 deletions(-) diff --git a/include/boost/beast/websocket/detail/decorator.hpp b/include/boost/beast/websocket/detail/decorator.hpp index 4bc6614d..1051cda0 100644 --- a/include/boost/beast/websocket/detail/decorator.hpp +++ b/include/boost/beast/websocket/detail/decorator.hpp @@ -16,7 +16,6 @@ #include #include #include -#include #include #include #include @@ -29,19 +28,24 @@ namespace detail { class decorator { + friend class decorator_test; + struct incomplete; + struct exemplar + { + void(incomplete::*mf)(); + std::shared_ptr sp; + void* param; + }; + static std::size_t constexpr Bytes = beast::detail::max_sizeof< void*, void const*, void(*)(), void(incomplete::*)(), - decltype(std::bind( - std::declval< - void(incomplete::*)(request_type&)>(), - std::shared_ptr{}, - std::placeholders::_1)) + exemplar >(); struct base @@ -69,28 +73,29 @@ class decorator struct none { + void + operator()(request_type&) + { + } + + void + operator()(response_type&) + { + } }; - template - struct is_req_op : std::false_type + // VFALCO NOTE: When this is two traits, one for + // request and one for response, + // Visual Studio 2015 fails. + + template + struct is_op_of : std::false_type { }; - template - struct is_req_op()(std::declval()) - )>> : std::true_type - { - }; - - template - struct is_res_op : std::false_type - { - }; - - template - struct is_res_op()(std::declval()) + template + struct is_op_of()(std::declval()) )>> : std::true_type { }; @@ -120,7 +125,8 @@ class decorator void invoke(request_type& req) override { - this->invoke(req, is_req_op{}); + this->invoke(req, + is_op_of{}); } void @@ -137,7 +143,8 @@ class decorator void invoke(response_type& res) override { - this->invoke(res, is_res_op{}); + this->invoke(res, + is_op_of{}); } void diff --git a/test/beast/websocket/_detail_decorator.cpp b/test/beast/websocket/_detail_decorator.cpp index ea62a30c..cf505d23 100644 --- a/test/beast/websocket/_detail_decorator.cpp +++ b/test/beast/websocket/_detail_decorator.cpp @@ -44,6 +44,9 @@ public: } }; + BOOST_STATIC_ASSERT(decorator::is_op_of< + req_t, request_type>::value); + struct res_t { bool pass_ = false; @@ -68,6 +71,9 @@ public: } }; + BOOST_STATIC_ASSERT(decorator::is_op_of< + res_t, response_type>::value); + struct both_t : res_t , req_t { using req_t::operator(); @@ -115,14 +121,6 @@ public: decorator d3; d3 = std::move(d2); } - - { - // this would be leaner with bind_front - decorator d(std::bind( - &decorator_test::dec_req, this, - std::placeholders::_1)); - BEAST_EXPECT(d.is_inline()); - } } void