type_traits.hh
Go to the documentation of this file.
1 //
2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
6 //
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
11 //
12 
13 
17 #ifndef HH_SENF_Utils_type_traits_
18 #define HH_SENF_Utils_type_traits_ 1
19 
20 // Custom includes
21 #include <boost/type_traits/function_traits.hpp>
22 #include <boost/type_traits/remove_pointer.hpp>
23 #include <boost/type_traits/is_function.hpp>
24 #include <boost/type_traits/remove_cv.hpp>
25 #include <boost/type_traits/remove_reference.hpp>
26 #include <boost/bind.hpp>
27 #include <senf/config.hh>
28 
29 #include "type_traits.mpp"
30 //-/////////////////////////////////////////////////////////////////////////////////////////////////
31 
32 namespace senf
33 {
34 
38  //\{
40 
59  template < class Traits, unsigned arity = Traits::arity >
61 
82  template < class Traits, int index, bool flag = (index < Traits::arity) >
83  struct function_traits_arg_type {};
84 
85 #ifndef DOXYGEN
86 
87  template < class Traits, int index >
89  {
90  typedef void type;
91  };
92 
93 #endif
94 
113  template < class MemberPointer > struct remove_member_pointer
114  {
115  typedef MemberPointer type;
116  };
117 
118 #ifndef DOXYGEN
119 
120  template < class C, class T > struct remove_member_pointer <T (C::*) >
121  {
122  typedef T type;
123  };
124 
125  template < class C, class T > struct remove_member_pointer <T (C::* const) >
126  {
127  typedef T type;
128  };
129 
130 #endif
131 
150  template < class MemberPointer > struct member_class
151  {
152  typedef void type;
153  };
154 
155 #ifndef DOXYGEN
156 
157  template < class C, class T > struct member_class <T (C::*) >
158  {
159  typedef C type;
160  };
161 
162  template < class C, class T > struct member_class <T (C::* const) >
163  {
164  typedef C type;
165  };
166 
167 #endif
168 
194  template < class T >
197  {};
198 
214  template < class T >
216  : public boost::is_function < typename senf::remove_any_pointer < T >::type >
217  {};
218 
232  template < class T >
234  : public boost::remove_cv< typename boost::remove_reference<T>::type >
235  {};
236 
246  template < class T >
248  : public boost::integral_constant<
249  unsigned,
250  boost::function_traits<
251  typename senf::remove_any_pointer<T>::type>::arity>
252  {};
253 
264  template <class Pair>
265  struct is_pair
266  : public boost::false_type
267  {};
268 
269 #ifndef DOXYGEN
270  template <class First, class Second>
271  struct is_pair< std::pair<First,Second> >
272  : public boost::true_type
273  {};
274 #endif
275 
276  //\}
277 
278 #ifndef DOXYGEN
279 
280 # define BOOST_PP_ITERATION_PARAMS_1 (4, (0, 10, \
281  SENF_ABSOLUTE_INCLUDE_PATH(Utils/type_traits.mpp), \
282  1))
283 # include BOOST_PP_ITERATE()
284 
285 #endif
286 
287 }
288 
289 //-/////////////////////////////////////////////////////////////////////////////////////////////////
290 //#include "type_traits.cci"
291 //#include "type_traits.ct"
292 //#include "type_traits.cti"
293 #endif
294 
295 
296 // Local Variables:
297 // mode: c++
298 // fill-column: 100
299 // comment-column: 40
300 // c-file-style: "senf"
301 // indent-tabs-mode: nil
302 // ispell-local-dictionary: "american"
303 // compile-command: "scons -u test"
304 // End:
Remove reference and CV qualification from type.
Definition: type_traits.hh:233
Test object if it is a function or member-function (pointer)
Definition: type_traits.hh:215
Get arity of function T.
Definition: type_traits.hh:247
u8 type
Strip first parameter from function traits.
Definition: type_traits.hh:60
Get class of a member pointer.
Definition: type_traits.hh:150
Remove any type of pointer from type.
Definition: type_traits.hh:195
Get argument type from function traits.
Definition: type_traits.hh:83
Remove member pointer from type.
Definition: type_traits.hh:113