• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*<-
2 Copyright Barrett Adair 2016-2017
3 Distributed under the Boost Software License, Version 1.0.
4 (See accompanying file LICENSE.md or copy at http ://boost.org/LICENSE_1_0.txt)
5 ->*/
6 
7 #include <boost/callable_traits/detail/config.hpp>
8 #ifdef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS
main()9 int main(){}
10 #else
11 
12 //[ overview
13 #include <boost/callable_traits.hpp>
14 
15 #include <type_traits>
16 #include <tuple>
17 
18 using std::is_same;
19 using std::tuple;
20 
21 using namespace boost::callable_traits;
22 
23 struct number {
24     int value;
addnumber25     int add(int n) const { return value + n; }
26 };
27 
28 using pmf = decltype(&number::add);
29 
30 //` Manipulate member functions pointers with ease:
31 static_assert(is_same<
32     remove_member_const_t<pmf>,
33     int(number::*)(int)
34 >{}, "");
35 
36 static_assert(is_same<
37     add_member_volatile_t<pmf>,
38     int(number::*)(int) const volatile
39 >{}, "");
40 
41 static_assert(is_same<
42     class_of_t<pmf>,
43     number
44 >{}, "");
45 
46 //` INVOKE-aware metafunctions:
47 
48 static_assert(is_same<
49     args_t<pmf>,
50     tuple<const number&, int>
51 >{}, "");
52 
53 static_assert(is_same<
54     return_type_t<pmf>,
55     int
56 >{}, "");
57 
58 static_assert(is_same<
59     function_type_t<pmf>,
60     int(const number&, int)
61 >{}, "");
62 
63 static_assert(is_same<
64     qualified_class_of_t<pmf>,
65     const number&
66 >{}, "");
67 
68 //` Here are a few other trait examples:
69 static_assert(is_const_member<pmf>{}, "");
70 static_assert(!is_volatile_member<pmf>{}, "");
71 static_assert(!has_void_return<pmf>{}, "");
72 static_assert(!has_varargs<pmf>{}, "");
73 
74 //]
75 
main()76 int main() {}
77 
78 #endif
79