switch to new MPL based Fraunhofer FOKUS Public License
[senf.git] / senf / Utils / type_traits.mpp
1 // $Id$
2 //
3 // Copyright (C) 2008
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 //
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at 
9 // http://senf.berlios.de/license.html
10 //
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on, 
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
14 //
15 // Software distributed under the License is distributed on an "AS IS" basis, 
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 
17 // for the specific language governing rights and limitations under the License.
18 //
19 // The Original Code is Fraunhofer FOKUS code.
20 //
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V. 
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 //
24 // Contributor(s):
25 //   Stefan Bund <g0dil@berlios.de>
26
27
28 /** \file
29     \brief type_traits Boost.Preprocesser external iteration include */
30
31 #if !BOOST_PP_IS_ITERATING && !defined(MPP_type_traits_)
32 #define MPP_type_traits_ 1
33
34 // Custom includes
35 #include <boost/preprocessor/iteration/iterate.hpp>
36 #include <boost/preprocessor/repetition/enum.hpp>
37 #include <boost/preprocessor/cat.hpp>
38 #include <boost/preprocessor/arithmetic/inc.hpp>
39 #include <boost/preprocessor/repetition/repeat_from_to.hpp>
40 #include <boost/preprocessor/punctuation/comma_if.hpp>
41 #include <boost/preprocessor/arithmetic/dec.hpp>
42 #include <boost/preprocessor/repetition/enum_trailing_params.hpp>
43 #include <boost/preprocessor/repetition/enum_params.hpp>
44
45 //-///////////////////////////mpp.p////////////////////////////////////////
46 #elif BOOST_PP_IS_ITERATING //-////////////////////////////////////////////
47 //-////////////////////////////////////////////////////////////////////////
48 // Local Macros
49
50 #define mpp_Arg(n) BOOST_PP_CAT(BOOST_PP_CAT(arg, BOOST_PP_INC(n)), _type)
51
52 #define mpp_OtherArgs_(z,n,d) BOOST_PP_COMMA_IF( BOOST_PP_DEC(n) ) typename traits::mpp_Arg(n)
53 #define mpp_OtherArgs() BOOST_PP_REPEAT_FROM_TO( 1, BOOST_PP_ITERATION(), mpp_OtherArgs_, _ )
54
55 #define mpp_ArgN() BOOST_PP_ITERATION()
56 #define mpp_CurArg() mpp_Arg(BOOST_PP_ITERATION())
57
58 #define mpp_TrailTplArgs() BOOST_PP_ENUM_TRAILING_PARAMS( BOOST_PP_ITERATION(), class A )
59 #define mpp_Args() BOOST_PP_ENUM_PARAMS( BOOST_PP_ITERATION(), A )
60
61 //-////////////////////////////////////////////////////////////////////////
62 #if BOOST_PP_ITERATION_FLAGS()==1 //-//////////////////////////////////////
63 //-////////////////////////////////////////////////////////////////////////
64
65 template <class Traits>
66 struct function_traits_remove_arg<Traits, mpp_ArgN()>
67 {
68     typedef Traits traits;
69     typedef boost::function_traits<typename traits::result_type( mpp_OtherArgs() )> type;
70 };
71
72 template < class C, class RV mpp_TrailTplArgs()>
73 struct remove_member_pointer<RV (C::*)(mpp_Args())>
74 {
75     typedef RV type (mpp_Args());
76 };
77
78 template < class C, class RV mpp_TrailTplArgs() >
79 struct member_class<RV (C::*)(mpp_Args())>
80 {
81     typedef C type;
82 };
83
84 template <class Traits>
85 struct function_traits_arg_type<Traits, mpp_ArgN(), true>
86 {
87     typedef typename Traits::mpp_CurArg() type;
88 };
89
90 template <class C, class T mpp_TrailTplArgs() >
91 struct remove_member_pointer <T (C::*)( mpp_Args() ) const>
92 {
93     typedef T type (mpp_Args());
94 };
95
96 template <class C, class T mpp_TrailTplArgs() >
97 struct remove_member_pointer <T (C::* const)( mpp_Args() ) const>
98 {
99     typedef T type (mpp_Args());
100 };
101
102 //-////////////////////////////////////////////////////////////////////////
103 #endif //-/////////////////////////////////////////////////////////////////
104 //-////////////////////////////////////////////////////////////////////////
105 // Undefine local Macros
106
107 #undef mpp_Args
108 #undef mpp_TrailTplArgs
109 #undef mpp_CurArg
110 #undef mpp_ArgN
111 #undef mpp_OtherArgs
112 #undef mpp_OtherArgs_
113 #undef mpp_Arg
114
115 //-////////////////////////////////////////////////////////////////////////
116 /*
117  (save-excursion (re-search-backward "^// Undefine local Macros")
118  (forward-line 1) (delete-region (point) (progn (search-forward
119  "//-////") (forward-line -1) (point))) (insert "\n") (let ((b (point))
120  (e (progn (insert (save-excursion (re-search-backward
121  "^// Local Macros") (search-forward "#define") (beginning-of-line)
122  (buffer-substring (point) (progn (search-forward "//-////")
123  (search-backward "#define") (forward-line 1) (point))))) (point))))
124  (reverse-region b e) (shell-command-on-region b e "grep -F '#define'" nil
125  t) (goto-char b) (while (looking-at "#define") (delete-char 7) (insert
126  "#undef") (skip-chars-forward " ") (re-search-forward "[^a-zA-Z0-9_]")
127  (delete-region (1- (point)) (progn (end-of-line) (point))) (forward-line
128  1))))
129 */
130 #endif //-/////////////////////////////////////////////////////////////////
131 //-///////////////////////////mpp.e////////////////////////////////////////
132
133 \f
134 // Local Variables:
135 // mode: c++
136 // fill-column: 100
137 // comment-column: 40
138 // c-file-style: "senf"
139 // indent-tabs-mode: nil
140 // ispell-local-dictionary: "american"
141 // compile-command: "scons -u test"
142 // End: