1 | |
---|
2 | // (C) Copyright John Maddock 2000. |
---|
3 | // Use, modification and distribution are subject to the |
---|
4 | // Boost Software License, Version 1.0. (See accompanying file |
---|
5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
---|
6 | |
---|
7 | #include "test.hpp" |
---|
8 | #include "check_type.hpp" |
---|
9 | #include "check_integral_constant.hpp" |
---|
10 | #ifdef TEST_STD |
---|
11 | # include <type_traits> |
---|
12 | #else |
---|
13 | # include <boost/type_traits/function_traits.hpp> |
---|
14 | #endif |
---|
15 | |
---|
16 | typedef void(pf_zero1)(); |
---|
17 | typedef int(pf_zero2)(); |
---|
18 | typedef const int& (pf_zero3)(); |
---|
19 | typedef void(pf_one1)(int); |
---|
20 | typedef int(pf_one2)(int); |
---|
21 | typedef const int&(pf_one3)(const int&); |
---|
22 | typedef void(pf_two1)(int,int); |
---|
23 | typedef int(pf_two2)(int,int); |
---|
24 | typedef const int&(pf_two3)(const int&,const int&); |
---|
25 | |
---|
26 | |
---|
27 | TT_TEST_BEGIN(function_traits) |
---|
28 | |
---|
29 | BOOST_CHECK_INTEGRAL_CONSTANT(::tt::function_traits<pf_zero1>::arity, 0); |
---|
30 | BOOST_CHECK_INTEGRAL_CONSTANT(::tt::function_traits<pf_zero2>::arity, 0); |
---|
31 | BOOST_CHECK_INTEGRAL_CONSTANT(::tt::function_traits<pf_zero3>::arity, 0); |
---|
32 | BOOST_CHECK_INTEGRAL_CONSTANT(::tt::function_traits<pf_one1>::arity, 1); |
---|
33 | BOOST_CHECK_INTEGRAL_CONSTANT(::tt::function_traits<pf_one2>::arity, 1); |
---|
34 | BOOST_CHECK_INTEGRAL_CONSTANT(::tt::function_traits<pf_one3>::arity, 1); |
---|
35 | BOOST_CHECK_INTEGRAL_CONSTANT(::tt::function_traits<pf_two1>::arity, 2); |
---|
36 | BOOST_CHECK_INTEGRAL_CONSTANT(::tt::function_traits<pf_two2>::arity, 2); |
---|
37 | BOOST_CHECK_INTEGRAL_CONSTANT(::tt::function_traits<pf_two3>::arity, 2); |
---|
38 | |
---|
39 | BOOST_CHECK_TYPE(void, ::tt::function_traits<pf_zero1>::result_type); |
---|
40 | BOOST_CHECK_TYPE(::tt::function_traits<pf_zero2>::result_type, int); |
---|
41 | BOOST_CHECK_TYPE(::tt::function_traits<pf_zero3>::result_type, const int&); |
---|
42 | BOOST_CHECK_TYPE(::tt::function_traits<pf_one1>::result_type, void); |
---|
43 | BOOST_CHECK_TYPE(::tt::function_traits<pf_one2>::result_type, int); |
---|
44 | BOOST_CHECK_TYPE(::tt::function_traits<pf_one3>::result_type, const int&); |
---|
45 | BOOST_CHECK_TYPE(::tt::function_traits<pf_two1>::result_type, void); |
---|
46 | BOOST_CHECK_TYPE(::tt::function_traits<pf_two2>::result_type, int); |
---|
47 | BOOST_CHECK_TYPE(::tt::function_traits<pf_two3>::result_type, const int&); |
---|
48 | |
---|
49 | BOOST_CHECK_TYPE(::tt::function_traits<pf_one1>::arg1_type, int); |
---|
50 | BOOST_CHECK_TYPE(::tt::function_traits<pf_one2>::arg1_type, int); |
---|
51 | BOOST_CHECK_TYPE(::tt::function_traits<pf_one3>::arg1_type, const int&); |
---|
52 | |
---|
53 | BOOST_CHECK_TYPE(::tt::function_traits<pf_two1>::arg1_type, int); |
---|
54 | BOOST_CHECK_TYPE(::tt::function_traits<pf_two2>::arg1_type, int); |
---|
55 | BOOST_CHECK_TYPE(::tt::function_traits<pf_two3>::arg1_type, const int&); |
---|
56 | BOOST_CHECK_TYPE(::tt::function_traits<pf_two1>::arg2_type, int); |
---|
57 | BOOST_CHECK_TYPE(::tt::function_traits<pf_two2>::arg2_type, int); |
---|
58 | BOOST_CHECK_TYPE(::tt::function_traits<pf_two3>::arg2_type, const int&); |
---|
59 | |
---|
60 | TT_TEST_END |
---|
61 | |
---|
62 | |
---|
63 | |
---|
64 | |
---|
65 | |
---|
66 | |
---|
67 | |
---|
68 | |
---|