is_invocable works with move-only types:

fix #652

Previously reported that function objects
taking move only types by value were not invocable.
This commit is contained in:
Robert Allan Hennigan Leahy
2017-07-14 22:22:03 -04:00
committed by Vinnie Falco
parent 2ea3240ed6
commit 27d070c724
3 changed files with 10 additions and 1 deletions

View File

@ -1,4 +1,5 @@
* Documentation tidying
* is_invocable works with move-only types
--------------------------------------------------------------------------------

View File

@ -15,6 +15,7 @@
#include <tuple>
#include <type_traits>
#include <string>
#include <utility>
// A few workarounds to keep things working
@ -108,7 +109,7 @@ template<class R, class C, class ...A>
auto
is_invocable_test(C&& c, int, A&& ...a)
-> decltype(std::is_convertible<
decltype(c(a...)), R>::value ||
decltype(c(std::forward<A>(a)...)), R>::value ||
std::is_same<R, void>::value,
std::true_type());

View File

@ -11,6 +11,7 @@
#include <boost/asio/ip/tcp.hpp>
#include <boost/asio/streambuf.hpp>
#include <boost/asio/detail/consuming_buffers.hpp>
#include <memory>
namespace beast {
@ -37,6 +38,11 @@ struct is_invocable_udt3
int operator()(int);
};
struct is_invocable_udt4
{
void operator()(std::unique_ptr<int>);
};
#ifndef __INTELLISENSE__
// VFALCO Fails to compile with Intellisense
BOOST_STATIC_ASSERT(is_invocable<is_invocable_udt1, void(int)>::value);
@ -46,6 +52,7 @@ BOOST_STATIC_ASSERT(! is_invocable<is_invocable_udt1, void(void)>::value);
BOOST_STATIC_ASSERT(! is_invocable<is_invocable_udt2, int(void)>::value);
BOOST_STATIC_ASSERT(! is_invocable<is_invocable_udt2, void(void)>::value);
BOOST_STATIC_ASSERT(! is_invocable<is_invocable_udt3 const, int(int)>::value);
BOOST_STATIC_ASSERT(is_invocable<is_invocable_udt4, void(std::unique_ptr<int>)>::value);
#endif
//