07558f113c89eca4d77afb3610d39b239cc93439
[senf.git] / senf / Utils / type_traits.mpp
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 Boost.Preprocesser external iteration include */
25
26 #if !BOOST_PP_IS_ITERATING && !defined(MPP_type_traits_)
27 #define MPP_type_traits_ 1
28
29 // Custom includes
30 #include <boost/preprocessor/iteration/iterate.hpp>
31 #include <boost/preprocessor/repetition/enum.hpp>
32 #include <boost/preprocessor/cat.hpp>
33 #include <boost/preprocessor/arithmetic/inc.hpp>
34 #include <boost/preprocessor/repetition/repeat_from_to.hpp>
35 #include <boost/preprocessor/punctuation/comma_if.hpp>
36 #include <boost/preprocessor/arithmetic/dec.hpp>
37 #include <boost/preprocessor/repetition/enum_trailing_params.hpp>
38 #include <boost/preprocessor/repetition/enum_params.hpp>
39
40 //-///////////////////////////mpp.p////////////////////////////////////////
41 #elif BOOST_PP_IS_ITERATING //-////////////////////////////////////////////
42 //-////////////////////////////////////////////////////////////////////////
43 // Local Macros
44
45 #define mpp_Arg(n) BOOST_PP_CAT(BOOST_PP_CAT(arg, BOOST_PP_INC(n)), _type)
46
47 #define mpp_OtherArgs_(z,n,d) BOOST_PP_COMMA_IF( BOOST_PP_DEC(n) ) typename traits::mpp_Arg(n)
48 #define mpp_OtherArgs() BOOST_PP_REPEAT_FROM_TO( 1, BOOST_PP_ITERATION(), mpp_OtherArgs_, _ )
49
50 #define mpp_ArgN() BOOST_PP_ITERATION()
51 #define mpp_CurArg() mpp_Arg(BOOST_PP_ITERATION())
52
53 #define mpp_TrailTplArgs() BOOST_PP_ENUM_TRAILING_PARAMS( BOOST_PP_ITERATION(), class A )
54 #define mpp_Args() BOOST_PP_ENUM_PARAMS( BOOST_PP_ITERATION(), A )
55
56 //-////////////////////////////////////////////////////////////////////////
57 #if BOOST_PP_ITERATION_FLAGS()==1 //-//////////////////////////////////////
58 //-////////////////////////////////////////////////////////////////////////
59
60 template <class Traits>
61 struct function_traits_remove_arg<Traits, mpp_ArgN()>
62 {
63     typedef Traits traits;
64     typedef boost::function_traits<typename traits::result_type( mpp_OtherArgs() )> type;
65 };
66
67 template < class C, class RV mpp_TrailTplArgs()>
68 struct remove_member_pointer<RV (C::*)(mpp_Args())>
69 {
70     typedef RV type (mpp_Args());
71 };
72
73 template < class C, class RV mpp_TrailTplArgs() >
74 struct member_class<RV (C::*)(mpp_Args())>
75 {
76     typedef C type;
77 };
78
79 template <class Traits>
80 struct function_traits_arg_type<Traits, mpp_ArgN(), true>
81 {
82     typedef typename Traits::mpp_CurArg() type;
83 };
84
85 template <class C, class T mpp_TrailTplArgs() >
86 struct remove_member_pointer <T (C::*)( mpp_Args() ) const>
87 {
88     typedef T type (mpp_Args());
89 };
90
91 template <class C, class T mpp_TrailTplArgs() >
92 struct remove_member_pointer <T (C::* const)( mpp_Args() ) const>
93 {
94     typedef T type (mpp_Args());
95 };
96
97 //-////////////////////////////////////////////////////////////////////////
98 #endif //-/////////////////////////////////////////////////////////////////
99 //-////////////////////////////////////////////////////////////////////////
100 // Undefine local Macros
101
102 #undef mpp_Args
103 #undef mpp_TrailTplArgs
104 #undef mpp_CurArg
105 #undef mpp_ArgN
106 #undef mpp_OtherArgs
107 #undef mpp_OtherArgs_
108 #undef mpp_Arg
109
110 //-////////////////////////////////////////////////////////////////////////
111 /*
112  (save-excursion (re-search-backward "^// Undefine local Macros")
113  (forward-line 1) (delete-region (point) (progn (search-forward
114  "//-////") (forward-line -1) (point))) (insert "\n") (let ((b (point))
115  (e (progn (insert (save-excursion (re-search-backward
116  "^// Local Macros") (search-forward "#define") (beginning-of-line)
117  (buffer-substring (point) (progn (search-forward "//-////")
118  (search-backward "#define") (forward-line 1) (point))))) (point))))
119  (reverse-region b e) (shell-command-on-region b e "grep -F '#define'" nil
120  t) (goto-char b) (while (looking-at "#define") (delete-char 7) (insert
121  "#undef") (skip-chars-forward " ") (re-search-forward "[^a-zA-Z0-9_]")
122  (delete-region (1- (point)) (progn (end-of-line) (point))) (forward-line
123  1))))
124 */
125 #endif //-/////////////////////////////////////////////////////////////////
126 //-///////////////////////////mpp.e////////////////////////////////////////
127
128 \f
129 // Local Variables:
130 // mode: c++
131 // fill-column: 100
132 // comment-column: 40
133 // c-file-style: "senf"
134 // indent-tabs-mode: nil
135 // ispell-local-dictionary: "american"
136 // compile-command: "scons -u test"
137 // End: