Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
typeseq-manip-test.cpp
Go to the documentation of this file.
1/*
2 TypeSeqManip(Test) - simple manipulations on type sequences
3
4 Copyright (C)
5 2008, Hermann Vosseler <Ichthyostega@web.de>
6
7  **Lumiera** is free software; you can redistribute it and/or modify it
8  under the terms of the GNU General Public License as published by the
9  Free Software Foundation; either version 2 of the License, or (at your
10  option) any later version. See the file COPYING for further details.
11
12* *****************************************************************/
13
14
31#include "lib/test/run.hpp"
35
36using std::string;
37
38
39namespace lib {
40namespace meta {
41namespace test {
42
43
44 namespace { // type-sequences to test with
45
47 , Num<2>
48 , Num<3>
49 >;
51 , Num<8>
52 , Num<9>
53 >;
54
55 } // (End) test data
56
57
58
59
60
61
62 /**********************************************************************/
69 class TypeSeqManip_test : public Test
70 {
71 virtual void
72 run (Arg)
73 {
77 check_shift ();
78 check_split ();
79 }
80
81
82 void
84 {
88// indexOfType<int>();
89// indexOfType<int,long,long>(); // does not compile...
90 }
91
92
93 void
95 {
97 EXPECT (LL, "-<1>-<2>-<3>-<7>-<8>-<9>-");
98
99 using Seq = Types<LL>::Seq;
100 using SeqList = Seq::List;
101 EXPECT (Seq, "-<1>-<2>-<3>-<7>-<8>-<9>-");
102 EXPECT (SeqList, "-<1>-<2>-<3>-<7>-<8>-<9>-");
103
105 EXPECT (NulS, "-");
106 }
107
108
109 void
111 {
112 using Prepend1 = Prepend<Num<5>, Types1 >; EXPECT (Prepend1, "-<5>-<1>-<2>-<3>-");
113 using Prepend2 = Prepend<Nil, Types1 >; EXPECT (Prepend2, "-<·>-<1>-<2>-<3>-");
114 using Prepend3 = Prepend<Num<5>, Types<>>; EXPECT (Prepend3, "-<5>-");
116 }
117
118
119 void
121 {
123 using Seq = Types<LL>::Seq;
124
125 using Seq_0 = Shifted<Seq,0>::Type; EXPECT (Seq_0, "-<7>-<8>-<9>-<1>-<2>-<3>-");
126 using Seq_1 = Shifted<Seq,1>::Type; EXPECT (Seq_1, "-<8>-<9>-<1>-<2>-<3>-");
127 using Seq_2 = Shifted<Seq,2>::Type; EXPECT (Seq_2, "-<9>-<1>-<2>-<3>-");
128 using Seq_3 = Shifted<Seq,3>::Type; EXPECT (Seq_3, "-<1>-<2>-<3>-");
129 using Seq_4 = Shifted<Seq,4>::Type; EXPECT (Seq_4, "-<2>-<3>-");
130 using Seq_5 = Shifted<Seq,5>::Type; EXPECT (Seq_5, "-<3>-");
131 using Seq_6 = Shifted<Seq,6>::Type; EXPECT (Seq_6, "-");
132
133 using Head_0 = Types<Shifted<Seq,0>::Head>; EXPECT (Head_0, "-<7>-");
134 using Head_1 = Types<Shifted<Seq,1>::Head>; EXPECT (Head_1, "-<8>-");
135 using Head_2 = Types<Shifted<Seq,2>::Head>; EXPECT (Head_2, "-<9>-");
136 using Head_3 = Types<Shifted<Seq,3>::Head>; EXPECT (Head_3, "-<1>-");
137 using Head_4 = Types<Shifted<Seq,4>::Head>; EXPECT (Head_4, "-<2>-");
138 using Head_5 = Types<Shifted<Seq,5>::Head>; EXPECT (Head_5, "-<3>-");
141 }
142
143
144 void
146 {
148 using Seq = Types<LL>::Seq; EXPECT (Seq , "-<1>-<2>-<3>-<7>-<8>-<9>-");
149
150 using List = Split<Seq>::List; EXPECT (List , "-<1>-<2>-<3>-<7>-<8>-<9>-");
151 using First = Split<Seq>::First; EXPECT (First , "-<1>-" );
152 using Tail = Split<Seq>::Tail; EXPECT (Tail , "-<2>-<3>-<7>-<8>-<9>-" );
153 using Prefix = Split<Seq>::Prefix; EXPECT (Prefix, "-<1>-<2>-<3>-<7>-<8>-" );
154 using Last = Split<Seq>::Last; EXPECT (Last , "-<9>-" );
155
156 using Head = Split<Seq>::Head;
157 using End = Split<Seq>::End;
158
159 using Ends = Types<Head,End>; EXPECT (Ends , "-<1>-<9>-");
160
161 using NoList = Split<Types<>>::List; EXPECT (NoList, "-");
162 using NoHead = Split<Types<>>::Head; EXPECT (NoHead, "-");
163 }
164
165
166 };
167
168
170 LAUNCHER (TypeSeqManip_test, "unit common");
171
172
173
174}}} // namespace lib::meta::test
Shifted< Tail, i-1 >::Type Type
Splice< LI, Nil, l >::Front Prefix
extract prefix of given length
enable_if_c< Cond::value, T >::type enable_if
SFINAE helper to control the visibility of specialisations and overloads.
Definition meta/util.hpp:87
Node< TY1, typename Append< TY2, Nil >::List > List
Helper: separate parts of a type sequence.
variadic sequence of types
Definition typelist.hpp:102
Implementation namespace for support and library code.
Test runner and basic definitions for tests.
Simplistic test class runner.
#define LAUNCHER(_TEST_CLASS_, _GROUPS_)
Definition run.hpp:116
Support for writing metaprogramming unit-tests dealing with typelists and flags.
#define EXPECT(_TY_, RENDERED_STRUCTURE)
Metaprogramming: Helpers for manipulating lists-of-types.
Some basic facilities for manipulating type sequences.