Move sourcecode into 'senf/' directory
[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 // ////////////////////////////////////////////////////////////////////////
51 #if BOOST_PP_ITERATION_FLAGS()==1 // //////////////////////////////////////
52 // ////////////////////////////////////////////////////////////////////////
53
54 template <class Traits>
55 struct function_traits_remove_arg<Traits, BOOST_PP_ITERATION()>
56 {
57     typedef Traits traits;
58     typedef boost::function_traits<typename traits::result_type( mpp_OtherArgs() )> type;
59 };
60
61 template < class C, class RV
62            BOOST_PP_ENUM_TRAILING_PARAMS( BOOST_PP_ITERATION(), class A ) >
63 struct remove_member_pointer<RV (C::*)(BOOST_PP_ENUM_PARAMS( BOOST_PP_ITERATION(), A ))>
64 {
65     typedef RV type (BOOST_PP_ENUM_PARAMS( BOOST_PP_ITERATION(), A ));
66 };
67
68 template < class C, class RV
69            BOOST_PP_ENUM_TRAILING_PARAMS( BOOST_PP_ITERATION(), class A ) >
70 struct member_class<RV (C::*)(BOOST_PP_ENUM_PARAMS( BOOST_PP_ITERATION(), A ))>
71 {
72     typedef C type;
73 };
74
75 template <class Traits>
76 struct function_traits_arg_type<Traits, BOOST_PP_ITERATION(), true>
77 {
78     typedef typename Traits::mpp_Arg(BOOST_PP_ITERATION()) type;
79 };
80
81 // ////////////////////////////////////////////////////////////////////////
82 #endif // /////////////////////////////////////////////////////////////////
83 // ////////////////////////////////////////////////////////////////////////
84 // Undefine local Macros
85
86 #undef mpp_OtherArgs_
87 #undef mpp_OtherArgs
88 #undef mpp_Arg
89
90 // ////////////////////////////////////////////////////////////////////////
91 #endif // /////////////////////////////////////////////////////////////////
92 // ///////////////////////////mpp.e////////////////////////////////////////
93
94 \f
95 // Local Variables:
96 // mode: c++
97 // fill-column: 100
98 // comment-column: 40
99 // c-file-style: "senf"
100 // indent-tabs-mode: nil
101 // ispell-local-dictionary: "american"
102 // compile-command: "scons -u test"
103 // End: