Lumiera  0.pre.03
»edit your freedom«
typeseq-manip-test.cpp
Go to the documentation of this file.
1 /*
2  TypeSeqManip(Test) - simple manipulations on type sequences
3 
4  Copyright (C) Lumiera.org
5  2008, Hermann Vosseler <Ichthyostega@web.de>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21 * *****************************************************/
22 
23 
40 #include "lib/test/run.hpp"
44 
45 using std::string;
46 using std::cout;
47 using std::endl;
48 
49 
50 namespace lib {
51 namespace meta {
52 namespace test {
53 
54 
55  namespace { // test data
56 
57 
58 
59  typedef Types< Num<1>
60  , Num<2>
61  , Num<3>
62  > Types1;
63  typedef Types< Num<7>
64  , Num<8>
65  , Num<9>
66  > Types2;
67 
68 
69  // see also the CountDown template in typelist-diagnostics.hpp...
70 
71  } // (End) test data
72 
73 
74 
75 
76 
77 
78  /**********************************************************************/
85  class TypeSeqManipl_test : public Test
86  {
87  virtual void
88  run (Arg)
89  {
90  check_buildSeq();
91  check_prepend ();
92  check_shift ();
93  check_split ();
94  }
95 
96 
97  void
98  check_buildSeq ()
99  {
101  DISPLAY (LL);
102 
103  typedef Types<LL>::Seq Seq;
104  typedef Seq::List SeqList;
105  DISPLAY (Seq);
106  DISPLAY (SeqList);
107 
108  typedef Types<NodeNull>::Seq NulS;
109  DISPLAY (NulS);
110  }
111 
112 
113  void
114  check_prepend ()
115  {
116  typedef Prepend<Num<5>, Types1> Prepend1;
117  DISPLAY(Prepend1);
118 
119  typedef Prepend<NullType, Types1> Prepend2;
120  DISPLAY(Prepend2);
121 
122  typedef Prepend<Num<5>, Types<> > Prepend3;
123  DISPLAY(Prepend3);
124 
125  typedef Prepend<NullType, Types<> > Prepend4;
126  DISPLAY(Prepend4);
127  }
128 
129 
130  void
131  check_shift ()
132  {
134  typedef Types<LL>::Seq Seq;
135 
136  typedef Shifted<Seq,0>::Type Seq_0; DISPLAY (Seq_0);
137  typedef Shifted<Seq,1>::Type Seq_1; DISPLAY (Seq_1);
138  typedef Shifted<Seq,2>::Type Seq_2; DISPLAY (Seq_2);
139  typedef Shifted<Seq,3>::Type Seq_3; DISPLAY (Seq_3);
140  typedef Shifted<Seq,4>::Type Seq_4; DISPLAY (Seq_4);
141  typedef Shifted<Seq,5>::Type Seq_5; DISPLAY (Seq_5);
142  typedef Shifted<Seq,6>::Type Seq_6; DISPLAY (Seq_6);
143 
144  typedef Types<Shifted<Seq,0>::Head> Head_0; DISPLAY (Head_0);
145  typedef Types<Shifted<Seq,1>::Head> Head_1; DISPLAY (Head_1);
146  typedef Types<Shifted<Seq,2>::Head> Head_2; DISPLAY (Head_2);
147  typedef Types<Shifted<Seq,3>::Head> Head_3; DISPLAY (Head_3);
148  typedef Types<Shifted<Seq,4>::Head> Head_4; DISPLAY (Head_4);
149  typedef Types<Shifted<Seq,5>::Head> Head_5; DISPLAY (Head_5);
150  typedef Types<Shifted<Seq,6>::Head> Head_6; DISPLAY (Head_6);
151  }
152 
153 
154  void
155  check_split ()
156  {
158  typedef Types<LL>::Seq Seq;
159  DISPLAY (Seq);
160 
161  typedef Split<Seq>::List List; DISPLAY(List);
162  typedef Split<Seq>::First First; DISPLAY(First);
163  typedef Split<Seq>::Tail Tail; DISPLAY(Tail);
164  typedef Split<Seq>::Prefix Prefix; DISPLAY(Prefix);
165  typedef Split<Seq>::Last Last; DISPLAY(Last);
166 
167  typedef Split<Seq>::Head Head;
168  typedef Split<Seq>::End End;
169 
170  typedef Types<Head,End> HeadEnd; DISPLAY(HeadEnd);
171  }
172 
173 
174  };
175 
176 
178  LAUNCHER (TypeSeqManipl_test, "unit common");
179 
180 
181 
182 }}} // namespace lib::meta::test
Definition: run.hpp:49
Some basic facilities for manipulating type sequences.
Helper: prepend a type to an existing type sequence, thus shifting all elements within the sequence t...
Implementation namespace for support and library code.
Simple test class runner.
Helper: separate parts of a type sequence.
Support for writing metaprogramming unit-tests dealing with typelists and flags.
Metaprogramming: Helpers for manipulating lists-of-types.
constant-wrapper type for debugging purposes, usable for generating lists of distinguishable types ...