33 using meta::is_Subclass;
69 auto h1 = F::build (1,2.3);
70 using C = F::Chain<bool,string>;
71 auto b2 = C::build (
true,
"Ψ");
73 C::AccessorFor<string> get4;
74 CHECK (get4(h1) ==
"Ψ");
83 CHECK ((
is_Subclass<Block1::NewFrame, std::tuple<uint,double>>()));
85 auto b1 = Block1::build (42, 1.61803);
86 CHECK (1.61803 == b1.get<1>());
87 CHECK (42 == b1.get<0>());
88 CHECK (
showType<Block1::Elm_t<0>>() ==
"uint"_expect);
89 CHECK (
showType<Block1::Elm_t<1>>() ==
"double"_expect);
92 CHECK (0.0 == b2.get<1>());
94 CHECK (3.14 == b2.get<1>());
96 CHECK (2 == std::tuple_size_v<Block1::NewFrame::Tuple>);
97 CHECK (2 == std::tuple_size_v<Block1::NewFrame>);
98 CHECK (2 == std::tuple_size_v<Block1>);
103 CHECK (3.14159 == b2.get<1>());
112 CHECK ((
is_Subclass<Block1::NewFrame, std::tuple<uint>>()));
114 using Constructor = Block1::Chain<double,string>;
115 using Block2 = Constructor::NewFrame;
116 CHECK ((
is_Subclass<Block2, std::tuple<double, string>>()));
118 auto b1 = Block1::build (41);
119 auto b2 = Constructor::build (1.61,
"Φ");
122 using Chain2 = Constructor::ChainType;
123 Chain2& chain2 = Constructor::recast (b1);
124 CHECK (b1.size() == 1);
125 CHECK (chain2.size() == 3);
127 CHECK (41 == chain2.get<0>());
128 CHECK (1.61 == chain2.get<1>());
129 CHECK (
"Φ" == chain2.get<2>());
132 chain2.get<1>() = (1 + sqrt(5)) / 2;
134 CHECK (b1.get<0>() == 42);
135 CHECK (chain2.get<0>() == 42);
136 CHECK (std::get<0> (b2) ==
"1.618034"_expect);
138 CHECK (isSameObject (chain2.get<0>() ,b1.get<0>()));
139 CHECK (isSameObject (chain2.get<2>() ,std::get<1>(b2)));
141 CHECK (1 == std::tuple_size_v<Block1::NewFrame::Tuple>);
142 CHECK (1 == std::tuple_size_v<Block1::NewFrame>);
143 CHECK (1 == std::tuple_size_v<Block1>);
145 CHECK (2 == std::tuple_size_v<Block2::Tuple>);
146 CHECK (2 == std::tuple_size_v<Block2>);
148 CHECK (3 == std::tuple_size_v<Chain2>);
149 CHECK ((
showType<std::tuple_element_t<0, Chain2>>() ==
"uint"_expect));
150 CHECK ((
showType<std::tuple_element_t<1, Chain2>>() ==
"double"_expect));
151 CHECK ((
showType<std::tuple_element_t<2, Chain2>>() ==
"string"_expect));
153 CHECK ((
showType<std::tuple_element_t<0, Block2>>() ==
"double"_expect));
154 CHECK ((
showType<std::tuple_element_t<1, Block2>>() ==
"string"_expect));
157 CHECK (std::get<0> (b2) ==
"1.618034"_expect);
161 CHECK (u0 ==
"42"_expect);
164 CHECK (v0 ==
"1.618034"_expect);
165 CHECK (v1 ==
"Φ"_expect);
167 auto& [x0,x1,x2] = chain2;
168 CHECK (x0 ==
"42"_expect);
169 CHECK (x1 ==
"1.618034"_expect);
170 CHECK (x2 ==
"Φ"_expect);
188 using Cons2 = Front::Chain<bool,string>;
189 using Data2 = Cons2::NewFrame;
190 using List2 = Cons2::ChainType;
191 using Acc4 = Cons2::AccessorFor<string>;
192 using Acc3 = Cons2::AccessorFor<bool>;
193 using Acc2 = Front::Accessor<1>;
194 using Acc1 = Front::Accessor<0>;
195 using Cons3 = Cons2::ChainExtent<CStr,string>;
196 using Data3 = Cons3::NewFrame;
197 using List3 = Cons3::ChainType;
198 using Acc5 = Cons3::AccessorFor<CStr>;
199 using Acc6 = Cons3::AccessorFor<string>;
200 CHECK (2 == Front::size());
201 CHECK (4 == List2::size());
202 CHECK (6 == List3::size());
209 CHECK (front.get<1>() == 0.0);
210 front.get<1>() = 2.3;
214 CHECK (Acc2::get(front) == 2.3);
218 CHECK (
sizeof(get4) == 1);
223 CHECK (Acc1::get(front) == 0);
224 CHECK (Acc2::get(front) == 2.3);
225 CHECK (Acc3::get(front) ==
false);
226 CHECK (get4(front) ==
"Ψ");
232 auto magic = Cons3::build(
"magic",
"cloud");
234 CHECK (magic.get<0>() ==
"magic"_expect);
235 CHECK (magic.get<1>() ==
"cloud"_expect);
237 magic.linkInto(front);
238 CHECK (get6(front) ==
"cloud");
244 Data3& d3 = evilSpace[0];
245 CHECK (isSameAdr (d3, loc));
246 CHECK (d3.get<0>() ==
"magic"_expect);
247 new(&d3.get<1>())
string{
"mushrooms"};
249 auto& [v1,v2,v3,v4,v5,v6] = Cons3::recast(front);
250 CHECK (v1 ==
"0"_expect);
251 CHECK (v2 ==
"2.3"_expect);
252 CHECK (v3 ==
"false"_expect);
253 CHECK (v4 ==
"Ψ"_expect);
254 CHECK (v5 ==
"magic"_expect);
255 CHECK (v6 ==
"mushrooms"_expect);
260 CHECK (front.get<0>() == 42);
261 CHECK (front.get<1>() == 5.5);
262 CHECK (d2.get<0>() ==
true);
263 CHECK (d2.get<1>() ==
"Ψ");
265 CHECK (isSameAdr (Acc1::get(front), v1));
266 CHECK (isSameAdr (Acc2::get(front), v2));
267 CHECK (isSameAdr (Acc3::get(front), v3));
268 CHECK (isSameAdr (Acc4::get(front), v4));
269 CHECK (isSameAdr (Acc5::get(front), v5));
270 CHECK (isSameAdr (Acc6::get(front), v6));
272 CHECK (not isSameAdr (front, v1));
273 CHECK (not isSameAdr (d2, v3));
274 CHECK (not isSameAdr (d3, v5));
276 List3& fullChain = Cons3::recast(front);
277 CHECK (isSameAdr (fullChain.get<2>(), std::get<0>(d2)));
278 CHECK (isSameAdr (fullChain.get<3>(), std::get<1>(d2)));
279 CHECK (isSameAdr (fullChain.get<4>(), std::get<0>(d3)));
280 CHECK (isSameAdr (fullChain.get<5>(), std::get<1>(d3)));
281 CHECK (isSameAdr (fullChain.get<0>(), v1));
282 CHECK (isSameAdr (fullChain.get<1>(), v2));
283 CHECK (isSameAdr (fullChain.get<2>(), v3));
284 CHECK (isSameAdr (fullChain.get<3>(), v4));
285 CHECK (isSameAdr (fullChain.get<4>(), v5));
286 CHECK (isSameAdr (fullChain.get<5>(), v6));
288 List2& partChain = Cons2::recast(fullChain);
289 CHECK (isSameAdr (partChain.get<0>(), v1));
290 CHECK (isSameAdr (partChain.get<1>(), v2));
291 CHECK (isSameAdr (partChain.get<2>(), v3));
292 CHECK (isSameAdr (partChain.get<3>(), v4));
302 CHECK (partChain.size() == 4);
303 auto& [w1,w2,w3,w4] = partChain;
304 CHECK (isSameObject (v1, w1));
305 CHECK (isSameObject (v2, w2));
306 CHECK (isSameObject (v3, w3));
307 CHECK (isSameObject (v4, w4));
Maintain a chained sequence of heterogeneous data blocks without allocation.
Implementation namespace for support and library code.
Simplistic test class runner.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
Block of raw uninitialised storage with array like access.
A setup with chained data tuples residing in distributed storage.
A collection of frequently used helper functions to support unit testing.
A raw memory block with proper alignment and array access.
Helpers for type detection, type rewriting and metaprogramming.
string showType()
diagnostic type output, including const and similar adornments
bool isSameAdr(A const &a, B const &b)
compare plain object address identity, disregarding type.
bool isSameObject(A const &a, B const &b)
compare plain object identity, based directly on the referee's memory identities. ...