Utils: Add some type traits in type_traits.hh
[senf.git] / Utils / type_traits.hh
1 // $Id$
2 //
3 // Copyright (C) 2008 
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 //     Stefan Bund <g0dil@berlios.de>
7 //
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22
23 /** \file
24     \brief type_traits public header */
25
26 #ifndef HH_type_traits_
27 #define HH_type_traits_ 1
28
29 // Custom includes
30 #include <boost/type_traits/function_traits.hpp>
31 #include <boost/type_traits/remove_pointer.hpp>
32 #include <boost/type_traits/is_function.hpp>
33 #include <boost/bind.hpp>
34
35 #include "type_traits.mpp"
36 ///////////////////////////////hh.p////////////////////////////////////////
37
38 namespace senf {
39
40     template <class Traits, unsigned arity=Traits::arity>
41     struct function_traits_remove_arg {};
42
43     template <class MemberPointer>
44     struct remove_member_pointer
45     {
46         typedef MemberPointer type;
47     };
48
49     template <class C, class T>
50     struct remove_member_pointer<T (C::*)>
51     {
52         typedef T type;
53     };
54
55     template <class MemberPointer>
56     struct member_class
57     {
58         typedef void type;
59     };
60
61     template <class C, class T>
62     struct member_class<T (C::*)>
63     {
64         typedef C type;
65     };
66
67     template <class T>
68     struct remove_any_pointer
69         : public remove_member_pointer<typename boost::remove_pointer<T>::type>
70     {};
71
72     template <class T>
73     struct is_any_function
74         : public boost::is_function<typename senf::remove_any_pointer<T>::type>
75     {};
76
77 #   define BOOST_PP_ITERATION_PARAMS_1 (4, (0, 10,                                                 \
78                                             SENF_ABSOLUTE_INCLUDE_PATH(Utils/type_traits.mpp), \
79                                             1))
80 #   include BOOST_PP_ITERATE()
81
82 }
83
84 ///////////////////////////////hh.e////////////////////////////////////////
85 //#include "type_traits.cci"
86 //#include "type_traits.ct"
87 //#include "type_traits.cti"
88 #endif
89
90 \f
91 // Local Variables:
92 // mode: c++
93 // fill-column: 100
94 // comment-column: 40
95 // c-file-style: "senf"
96 // indent-tabs-mode: nil
97 // ispell-local-dictionary: "american"
98 // compile-command: "scons -u test"
99 // End: