1 /*
2 
3 @Copyright Barrett Adair 2015-2017
4 Distributed under the Boost Software License, Version 1.0.
5 (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
6 
7 */
8 
9 #ifndef BOOST_CLBL_TRTS_DETAIL_FUNCTION_HPP
10 #define BOOST_CLBL_TRTS_DETAIL_FUNCTION_HPP
11 
12 #include <boost/callable_traits/detail/config.hpp>
13 #include <boost/callable_traits/detail/qualifier_flags.hpp>
14 #include <boost/callable_traits/detail/forward_declarations.hpp>
15 #include <boost/callable_traits/detail/set_function_qualifiers.hpp>
16 #include <boost/callable_traits/detail/default_callable_traits.hpp>
17 
18 namespace boost { namespace callable_traits { namespace detail {
19 
20 template<typename T>
21 struct function : default_callable_traits<T> {};
22 
23 #undef BOOST_CLBL_TRTS_INCLUDE_QUALIFIERS
24 #define BOOST_CLBL_TRTS_INCLUDE_QUALIFIERS
25 #include <boost/callable_traits/detail/unguarded/function.hpp>
26 #undef BOOST_CLBL_TRTS_INCLUDE_QUALIFIERS
27 
28 #ifndef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS
29 
30 #define BOOST_CLBL_TRTS_INCLUDE_QUALIFIERS const
31 #include <boost/callable_traits/detail/unguarded/function.hpp>
32 #undef BOOST_CLBL_TRTS_INCLUDE_QUALIFIERS
33 
34 #define BOOST_CLBL_TRTS_INCLUDE_QUALIFIERS volatile
35 #include <boost/callable_traits/detail/unguarded/function.hpp>
36 #undef BOOST_CLBL_TRTS_INCLUDE_QUALIFIERS
37 
38 #define BOOST_CLBL_TRTS_INCLUDE_QUALIFIERS const volatile
39 #include <boost/callable_traits/detail/unguarded/function.hpp>
40 #undef BOOST_CLBL_TRTS_INCLUDE_QUALIFIERS
41 
42 #ifndef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS
43 
44 #define BOOST_CLBL_TRTS_INCLUDE_QUALIFIERS &
45 #include <boost/callable_traits/detail/unguarded/function.hpp>
46 #undef BOOST_CLBL_TRTS_INCLUDE_QUALIFIERS
47 
48 #define BOOST_CLBL_TRTS_INCLUDE_QUALIFIERS &&
49 #include <boost/callable_traits/detail/unguarded/function.hpp>
50 #undef BOOST_CLBL_TRTS_INCLUDE_QUALIFIERS
51 
52 #define BOOST_CLBL_TRTS_INCLUDE_QUALIFIERS const &
53 #include <boost/callable_traits/detail/unguarded/function.hpp>
54 #undef BOOST_CLBL_TRTS_INCLUDE_QUALIFIERS
55 
56 #define BOOST_CLBL_TRTS_INCLUDE_QUALIFIERS const &&
57 #include <boost/callable_traits/detail/unguarded/function.hpp>
58 #undef BOOST_CLBL_TRTS_INCLUDE_QUALIFIERS
59 
60 #define BOOST_CLBL_TRTS_INCLUDE_QUALIFIERS volatile &
61 #include <boost/callable_traits/detail/unguarded/function.hpp>
62 #undef BOOST_CLBL_TRTS_INCLUDE_QUALIFIERS
63 
64 #define BOOST_CLBL_TRTS_INCLUDE_QUALIFIERS volatile &&
65 #include <boost/callable_traits/detail/unguarded/function.hpp>
66 #undef BOOST_CLBL_TRTS_INCLUDE_QUALIFIERS
67 
68 #define BOOST_CLBL_TRTS_INCLUDE_QUALIFIERS const volatile &
69 #include <boost/callable_traits/detail/unguarded/function.hpp>
70 #undef BOOST_CLBL_TRTS_INCLUDE_QUALIFIERS
71 
72 #define BOOST_CLBL_TRTS_INCLUDE_QUALIFIERS const volatile &&
73 #include <boost/callable_traits/detail/unguarded/function.hpp>
74 #undef BOOST_CLBL_TRTS_INCLUDE_QUALIFIERS
75 
76 #endif // #ifndef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS
77 #endif // #ifndef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS
78 
79 // function pointers
80 
81 #define BOOST_CLBL_TRTS_CC_TAG dummy
82 #define BOOST_CLBL_TRTS_VARARGS_CC BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC
83 #define BOOST_CLBL_TRTS_CC
84 #define BOOST_CLBL_TRTS_ST
85 #include <boost/callable_traits/detail/unguarded/function_ptr.hpp>
86 #include <boost/callable_traits/detail/unguarded/function_ptr_varargs.hpp>
87 #undef BOOST_CLBL_TRTS_ST
88 #undef BOOST_CLBL_TRTS_CC
89 #undef BOOST_CLBL_TRTS_CC_TAG
90 #undef BOOST_CLBL_TRTS_VARARGS_CC
91 
92 /* ?
93 #ifdef BOOST_CLBL_TRTS_ENABLE_CDECL
94 #define BOOST_CLBL_TRTS_CC_TAG cdecl_tag
95 #define BOOST_CLBL_TRTS_VARARGS_CC __cdecl
96 #define BOOST_CLBL_TRTS_CC __cdecl
97 #define BOOST_CLBL_TRTS_ST
98 #include <boost/callable_traits/detail/unguarded/function_ptr.hpp>
99 #undef BOOST_CLBL_TRTS_ST
100 #undef BOOST_CLBL_TRTS_CC
101 #undef BOOST_CLBL_TRTS_CC_TAG
102 #undef BOOST_CLBL_TRTS_VARARGS_CC
103 #endif*/
104 
105 #ifdef BOOST_CLBL_TRTS_ENABLE_STDCALL
106 #define BOOST_CLBL_TRTS_CC_TAG stdcall_tag
107 #define BOOST_CLBL_TRTS_VARARGS_CC BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC
108 #define BOOST_CLBL_TRTS_CC __stdcall
109 #define BOOST_CLBL_TRTS_ST
110 #include <boost/callable_traits/detail/unguarded/function_ptr.hpp>
111 #undef BOOST_CLBL_TRTS_ST
112 #undef BOOST_CLBL_TRTS_CC
113 #undef BOOST_CLBL_TRTS_CC_TAG
114 #undef BOOST_CLBL_TRTS_VARARGS_CC
115 #endif
116 
117 #ifdef BOOST_CLBL_TRTS_ENABLE_FASTCALL
118 #define BOOST_CLBL_TRTS_CC_TAG fastcall_tag
119 #define BOOST_CLBL_TRTS_VARARGS_CC BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC
120 #define BOOST_CLBL_TRTS_CC __fastcall
121 #define BOOST_CLBL_TRTS_ST
122 #include <boost/callable_traits/detail/unguarded/function_ptr.hpp>
123 #undef BOOST_CLBL_TRTS_CC
124 #undef BOOST_CLBL_TRTS_ST
125 #undef BOOST_CLBL_TRTS_CC_TAG
126 #undef BOOST_CLBL_TRTS_VARARGS_CC
127 #endif
128 
129 #ifdef BOOST_CLBL_TRTS_ENABLE_PASCAL
130 #define BOOST_CLBL_TRTS_CC_TAG pascal_tag
131 #define BOOST_CLBL_TRTS_VARARGS_CC BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC
132 #define BOOST_CLBL_TRTS_CC
133 #define BOOST_CLBL_TRTS_ST pascal
134 #include <boost/callable_traits/detail/unguarded/function_ptr.hpp>
135 #undef BOOST_CLBL_TRTS_CC
136 #undef BOOST_CLBL_TRTS_ST
137 #undef BOOST_CLBL_TRTS_CC_TAG
138 #undef BOOST_CLBL_TRTS_VARARGS_CC
139 #endif
140 
141 template<typename T>
142 struct function<T&> : std::conditional<function<T>::value,
143     function<T>, default_callable_traits<T&>>::type {
144 
145     static constexpr const bool value = !std::is_pointer<T>::value;
146 
147     using traits = function;
148     using base = function<T>;
149     using type = T&;
150     using remove_varargs = typename base::remove_varargs&;
151     using add_varargs = typename base::add_varargs&;
152 
153     using remove_member_reference = reference_error;
154     using add_member_lvalue_reference = reference_error;
155     using add_member_rvalue_reference = reference_error;
156     using add_member_const = reference_error;
157     using add_member_volatile = reference_error;
158     using add_member_cv = reference_error;
159     using remove_member_const = reference_error;
160     using remove_member_volatile = reference_error;
161     using remove_member_cv = reference_error;
162 
163     template<typename NewReturn>
164     using apply_return = typename base::template apply_return<NewReturn>&;
165 
166     using clear_args = typename base::clear_args&;
167 
168     template<typename... NewArgs>
169     using push_front = typename base::template push_front<NewArgs...>&;
170 
171     template<typename... NewArgs>
172     using push_back = typename base::template push_back<NewArgs...>&;
173 
174     template<std::size_t Count>
175     using pop_back = typename base::template pop_back<Count>&;
176 
177     template<std::size_t Count>
178     using pop_front = typename base::template pop_front<Count>&;
179 
180     template<std::size_t Index, typename... NewArgs>
181     using insert_args = typename base::template insert_args<Index, NewArgs...>&;
182 
183     template<std::size_t Index, std::size_t Count>
184     using remove_args = typename base::template remove_args<Index, Count>&;
185 
186     template<std::size_t Index, typename... NewArgs>
187     using replace_args = typename base::template replace_args<Index, NewArgs...>&;
188 };
189 
190 }}} // namespace boost::callable_traits::detail
191 
192 #endif // #ifndef BOOST_CLBL_TRTS_DETAIL_FUNCTION_HPP
193