1 | // (C) Copyright John Maddock 2005. |
---|
2 | // Use, modification and distribution are subject to the |
---|
3 | // Boost Software License, Version 1.0. (See accompanying file |
---|
4 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
---|
5 | |
---|
6 | #ifdef TEST_STD_HEADERS |
---|
7 | #include <functional> |
---|
8 | #else |
---|
9 | #include <boost/tr1/functional.hpp> |
---|
10 | #endif |
---|
11 | |
---|
12 | #include <boost/static_assert.hpp> |
---|
13 | #include <boost/type_traits/is_same.hpp> |
---|
14 | #define NO_INHERT_TEST |
---|
15 | #include "verify_functor.hpp" |
---|
16 | |
---|
17 | struct expected_result |
---|
18 | { |
---|
19 | expected_result(){} |
---|
20 | }; |
---|
21 | |
---|
22 | struct test |
---|
23 | { |
---|
24 | expected_result field; |
---|
25 | expected_result nullary(); |
---|
26 | expected_result nullary_c()const; |
---|
27 | expected_result nullary_v()volatile; |
---|
28 | expected_result nullary_cv()const volatile; |
---|
29 | expected_result unary(int); |
---|
30 | expected_result unary_c(int)const; |
---|
31 | expected_result unary_v(int)volatile; |
---|
32 | expected_result unary_cv(int)const volatile; |
---|
33 | }; |
---|
34 | |
---|
35 | int main() |
---|
36 | { |
---|
37 | verify_field_functor(std::tr1::mem_fn(&test::field), std::unary_function<test const*, const expected_result&>()); |
---|
38 | verify_field_functor(std::tr1::mem_fn(&test::field), std::unary_function<test*, expected_result&>()); |
---|
39 | verify_unary_functor(std::tr1::mem_fn(&test::nullary), std::unary_function<test*, expected_result>()); |
---|
40 | verify_unary_functor(std::tr1::mem_fn(&test::nullary_c), std::unary_function<test const*, expected_result>()); |
---|
41 | //verify_unary_functor(std::tr1::mem_fn(&test::nullary_v), std::unary_function<test volatile*, expected_result>()); |
---|
42 | //verify_unary_functor(std::tr1::mem_fn(&test::nullary_cv), std::unary_function<test const volatile*, expected_result>()); |
---|
43 | |
---|
44 | verify_binary_functor(std::tr1::mem_fn(&test::unary), std::binary_function<test*, int, expected_result>()); |
---|
45 | verify_binary_functor(std::tr1::mem_fn(&test::unary_c), std::binary_function<test const*, int, expected_result>()); |
---|
46 | //verify_binary_functor(std::tr1::mem_fn(&test::unary_v), std::binary_function<test volatile*, int, expected_result>()); |
---|
47 | //verify_binary_functor(std::tr1::mem_fn(&test::unary_cv), std::binary_function<test const volatile*, int, expected_result>()); |
---|
48 | return 0; |
---|
49 | } |
---|
50 | |
---|