-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathis_functor.hpp
48 lines (41 loc) · 1.42 KB
/
is_functor.hpp
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
//
// Copyright Mathieu Champlon 2009
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef MOCK_IS_FUNCTOR_HPP_INCLUDED
#define MOCK_IS_FUNCTOR_HPP_INCLUDED
#include "yes_no_type.hpp"
#include <boost/function_types/is_callable_builtin.hpp>
#include <boost/type_traits/integral_constant.hpp>
#include <boost/type_traits/detail/yes_no_type.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/mpl/or.hpp>
namespace mock
{
namespace detail
{
#define MOCK_IS_FUNCTION_HELPER(N, M) \
template< typename T > yes_type& N##_helper( BOOST_DEDUCED_TYPENAME T::M* ); \
template< typename T > no_type& N##_helper( ... ); \
template< typename T > struct N \
: boost::mpl::bool_< sizeof( N##_helper< T >( 0 ) ) == sizeof( yes_type ) > \
{};
MOCK_IS_FUNCTION_HELPER( has_result_type, result_type )
MOCK_IS_FUNCTION_HELPER( has_sig, BOOST_NESTED_TEMPLATE sig< void > )
MOCK_IS_FUNCTION_HELPER( has_result, BOOST_NESTED_TEMPLATE result< void > )
#undef MOCK_IS_FUNCTION_HELPER
template< typename T >
struct is_functor
: boost::mpl::or_<
boost::function_types::is_callable_builtin< T >,
has_result_type< T >,
has_result< T >,
has_sig< T >
>
{};
}
}
#endif // MOCK_IS_FUNCTOR_HPP_INCLUDED