]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // |
2 | // Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) | |
3 | // | |
4 | // Distributed under the Boost Software License, Version 1.0. (See accompanying | |
5 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
6 | // | |
7 | ||
8 | #ifndef BEAST_DETAIL_IS_CALL_POSSIBLE_HPP | |
9 | #define BEAST_DETAIL_IS_CALL_POSSIBLE_HPP | |
10 | ||
11 | #include <type_traits> | |
12 | ||
13 | namespace beast { | |
14 | namespace detail { | |
15 | ||
16 | template<class R, class C, class ...A> | |
17 | auto | |
18 | is_call_possible_test(C&& c, int, A&& ...a) | |
19 | -> decltype(std::is_convertible< | |
20 | decltype(c(a...)), R>::value || | |
21 | std::is_same<R, void>::value, | |
22 | std::true_type()); | |
23 | ||
24 | template<class R, class C, class ...A> | |
25 | std::false_type | |
26 | is_call_possible_test(C&& c, long, A&& ...a); | |
27 | ||
28 | /** Metafunction returns `true` if F callable as R(A...) | |
29 | ||
30 | Example: | |
31 | ||
32 | @code | |
33 | is_call_possible<T, void(std::string)> | |
34 | @endcode | |
35 | */ | |
36 | /** @{ */ | |
37 | template<class C, class F> | |
38 | struct is_call_possible | |
39 | : std::false_type | |
40 | { | |
41 | }; | |
42 | ||
43 | template<class C, class R, class ...A> | |
44 | struct is_call_possible<C, R(A...)> | |
45 | : decltype(is_call_possible_test<R>( | |
46 | std::declval<C>(), 1, std::declval<A>()...)) | |
47 | { | |
48 | }; | |
49 | /** @} */ | |
50 | ||
51 | } // detail | |
52 | } // beast | |
53 | ||
54 | #endif |