liuxiaolong
2021-07-20 58d904a328c0d849769b483e901a0be9426b8209
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#ifndef BOOST_CLBL_TRTS_DETAIL_FORWARD_DECLARATIONS
#define BOOST_CLBL_TRTS_DETAIL_FORWARD_DECLARATIONS
#include <boost/callable_traits/detail/config.hpp>
#include <boost/callable_traits/detail/default_callable_traits.hpp>
 
namespace boost { namespace callable_traits { namespace detail {
 
template<typename T>
struct function;
 
template<typename T>
struct has_normal_call_operator
{
    template<typename N, N Value>
    struct check { check(std::nullptr_t) {} };
 
    template<typename U>
    static std::int8_t test(
        check<decltype(&U::operator()), &U::operator()>);
 
    template<typename>
    static std::int16_t test(...);
 
    static constexpr bool value =
        sizeof(test<T>(nullptr)) == sizeof(std::int8_t);
};
 
struct callable_dummy {
    void operator()() {}
};
 
template<typename T>
using default_to_function_object = typename std::conditional<
    has_normal_call_operator<T>::value,
    T, callable_dummy>::type;
 
template<typename T>
struct pmf;
 
template<typename T>
struct pmd;
 
template<typename F, typename T = typename std::remove_reference<F>::type>
using function_object_base = typename std::conditional<
    has_normal_call_operator<T>::value,
    pmf<decltype(&default_to_function_object<T>::operator())>,
    default_callable_traits<T>>::type;
 
template<typename T, typename Base = function_object_base<T>>
struct function_object;
 
}}} // namespace boost::callable_traits::detail
 
#endif // #ifndef BOOST_CLBL_TRTS_DETAIL_FORWARD_DECLARATIONS