uLib-0.2
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Mpl.h
Go to the documentation of this file.
1 /*//////////////////////////////////////////////////////////////////////////////
2 // CMT Cosmic Muon Tomography project //////////////////////////////////////////
4 
5  Copyright (c) 2014, Universita' degli Studi di Padova, INFN sez. di Padova
6  All rights reserved
7 
8  Authors: Andrea Rigoni Garola < andrea.rigoni@pd.infn.it >
9 
10  ------------------------------------------------------------------
11  This library is free software; you can redistribute it and/or
12  modify it under the terms of the GNU Lesser General Public
13  License as published by the Free Software Foundation; either
14  version 3.0 of the License, or (at your option) any later version.
15 
16  This library is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  Lesser General Public License for more details.
20 
21  You should have received a copy of the GNU Lesser General Public
22  License along with this library.
23 
25 
26 
27 
28 #ifndef U_MPL_H
29 #define U_MPL_H
30 
31 #include <boost/preprocessor.hpp>
32 
33 #include <boost/mpl/fold.hpp>
34 #include <boost/mpl/inherit_linearly.hpp>
35 #include <boost/mpl/inherit.hpp>
36 
37 #include <boost/mpl/vector.hpp>
38 #include <boost/mpl/vector/vector0.hpp>
39 #include <boost/mpl/vector/vector10.hpp>
40 #include <boost/mpl/vector/vector20.hpp>
41 #include <boost/mpl/copy.hpp>
42 
43 #include <boost/mpl/transform.hpp>
44 #include <boost/mpl/transform_view.hpp>
45 #include <boost/mpl/filter_view.hpp>
46 
47 #include <boost/mpl/list.hpp>
48 #include <boost/mpl/string.hpp>
49 #include <boost/mpl/for_each.hpp>
50 #include <boost/mpl/has_xxx.hpp>
51 
52 #include <boost/utility/enable_if.hpp>
53 
57 #ifndef ULIB_CFG_MPL_INERIT_NOFOLD_MAXSIZE
58 # define ULIB_CFG_MPL_INERIT_NOFOLD_MAXSIZE 10
59 #endif
60 
61 namespace uLib {
62 
63 namespace mpl {
64 
65 using namespace boost::mpl;
66 using namespace boost::mpl::placeholders;
67 
68 //using boost::enable_if;
69 
70 namespace detail {
71 
77 template <class TypeSeq, unsigned int size>
78 struct inherit_nofold {};
79 
80 // Horizontal repetition macro //
81 #define _INERIT_NOFOLD_H(hz,hn,hdata) \
82  BOOST_PP_COMMA_IF(hn) \
83  mpl::at<TypeSeq,mpl::int_<hn> >::type
84 
85 // Veritical repetition macro //
86 #define _INERIT_NOFOLD_V(vz,vn,vdata) \
87  template <class TypeSeq> \
88  struct inherit_nofold<TypeSeq,BOOST_PP_INC(vn)> : \
89  BOOST_PP_REPEAT(BOOST_PP_INC(vn),_INERIT_NOFOLD_H,~) \
90  {};
91 
92 // Multiple size declaration //
93 BOOST_PP_REPEAT(ULIB_CFG_MPL_INERIT_NOFOLD_MAXSIZE,_INERIT_NOFOLD_V,~)
94 
95 #undef _INERIT_NOFOLD_H
96 #undef _INERIT_NOFOLD_V
97 
98 
99 } // detail
100 
106 template <class TypeSeq>
107 struct inherit_nofold {
108  typedef detail::inherit_nofold< TypeSeq, mpl::size<TypeSeq>::type::value > type;
109 };
110 
112 #define ULIB_MPL_INHERIT_SEQ(_TypeList) \
113  uLib::mpl::inherit_linearly< _TypeList, mpl::inherit< mpl::_1, mpl::_2 > >::type
114 
116 #define ULIB_MPL_INHERIT_NOFOLD_SEQ(_TypeList) \
117  uLib::mpl::inherit_nofold< _TypeList >::type
118 
119 
120 
121 
122 template< class T>
123 struct type {
124 
125 };
126 
127 template <const char *N, class T>
128 struct nvp {
129  nvp() : name(N) {}
130  const char *name;
131  typedef T type;
132 };
133 
134 
135 } // mpl
136 
137 } // uLib
138 
139 #endif // MPL_H