fw4spl
Combinatory.hpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2017.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 // fwTools - copyright (C) 2005 IRCAD.
8 #ifndef __FWTOOLS_COMBINATORY_HPP__
9 #define __FWTOOLS_COMBINATORY_HPP__
10 
11 #include <boost/mpl/accumulate.hpp>
12 #include <boost/mpl/apply.hpp>
13 #include <boost/mpl/back_inserter.hpp>
14 #include <boost/mpl/copy.hpp>
15 #include <boost/mpl/empty.hpp>
16 #include <boost/mpl/eval_if.hpp>
17 #include <boost/mpl/placeholders.hpp>
18 #include <boost/mpl/push_front.hpp>
19 #include <boost/mpl/transform.hpp>
20 #include <boost/mpl/vector.hpp>
21 
22 namespace fwTools
23 {
24 
36 {
37  template<class TYPE, class SETOFSET>
38  struct apply
39  {
40 
41  typedef BOOST_DEDUCED_TYPENAME boost::mpl::eval_if< boost::mpl::empty<SETOFSET>,
42  boost::mpl::vector< boost::mpl::vector<TYPE> >,
43  boost::mpl::transform< SETOFSET,
44  boost::mpl::push_front< boost::mpl::
45  _1, TYPE > >
46  >::type type;
47  };
48 };
49 
54 {
55  template<class T>
56  struct apply
57  {
58  typedef BOOST_DEDUCED_TYPENAME boost::mpl::vector< T >:: type type;
59  };
60 };
61 
67 {
68  template<class Set>
69  struct apply
70  {
71  typedef BOOST_DEDUCED_TYPENAME boost::mpl::transform<Set, make_vector >::type type;
72  };
73 };
74 
85 {
86  template< class Set1, class MultiSet >
87  struct apply
88  {
89  typedef BOOST_DEDUCED_TYPENAME boost::mpl::accumulate< Set1,
90  boost::mpl::vector<>,
91  boost::mpl::copy< boost::mpl::apply2< AppendValueFirst,
92  boost::mpl::_2,
93  MultiSet >,
94  boost::mpl::back_inserter< boost::mpl
95  ::_1> >
96 
97  >::type type;
98  };
99 };
100 
138 {
139  template< class Set1, class Set2 >
140  struct apply
141  {
142  typedef BOOST_DEDUCED_TYPENAME boost::mpl::apply1< makeSetOfSingletons, Set2>::type Set2WithSingletons;
143 
144  typedef BOOST_DEDUCED_TYPENAME boost::mpl::apply2<BinaryCartesianProductRecurser, Set1,
145  Set2WithSingletons >::type type;
146  };
147 };
148 
184 {
185  template< class MultiSet >
186  struct apply
187  {
188  typedef BOOST_DEDUCED_TYPENAME boost::mpl::reverse_fold< MultiSet,
189  boost::mpl::vector<>,
190  boost::mpl::apply2< BinaryCartesianProductRecurser,
191  boost::mpl::_2, boost::mpl::_1 >
192  >::type type;
193  };
194 };
195 
196 } //end namespace fwTools
197 
198 #endif /*__FWTOOLS_COMBINATORY_HPP__*/
The namespace fwTools contains several tools like UUID, factory, dispatche, stringizer, macros, helper.
MetaFunction which create an boost::boost::mpl::vector.
Definition: Combinatory.hpp:53
compute the cartesian product of many set
Compute Cartesian Product of two set (type list) to generate all possible combinaison.
Helper which compute from a set and a multi set.
Definition: Combinatory.hpp:84
Helper for BinaryCartesianProduct two Set.
Definition: Combinatory.hpp:35
MetaFunction ( used for pseudo Curryfication ) which transform a set where new elements are singleton...
Definition: Combinatory.hpp:66