Embedded Template Library 1.0
Loading...
Searching...
No Matches
variant_pool_cpp03_generator.h
1/******************************************************************************
2The MIT License(MIT)
3
4Embedded Template Library.
5https://github.com/ETLCPP/etl
6https://www.etlcpp.com
7
8Copyright(c) 2026 John Wellbelove
9
10Permission is hereby granted, free of charge, to any person obtaining a copy
11of this software and associated documentation files(the "Software"), to deal
12in the Software without restriction, including without limitation the rights
13to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
14copies of the Software, and to permit persons to whom the Software is
15furnished to do so, subject to the following conditions :
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
23AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26SOFTWARE.
27******************************************************************************/
28
29//***************************************************************************
30// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.
31//***************************************************************************
32
33//***************************************************************************
34/*[[[cog
35import cog
36cog.outl("template <size_t MAX_SIZE_,")
37cog.outl(" typename T1,")
38for n in range(2, int(NTypes)):
39 cog.outl(" typename T%s = void," % n)
40cog.outl(" typename T%s = void>" % int(NTypes))
41cog.outl("class variant_pool")
42cog.out(" : public etl::generic_pool<")
43cog.out("etl::largest<")
44for n in range(1, int(NTypes)):
45 cog.out("T%s, " % n)
46cog.outl("T%s>::size," % int(NTypes))
47cog.out(" etl::largest<")
48for n in range(1, int(NTypes)):
49 cog.out("T%s, " % n)
50cog.outl("T%s>::alignment," % int(NTypes))
51cog.outl(" MAX_SIZE_>")
52]]]*/
53/*[[[end]]]*/
54{
55public:
56
57 /*[[[cog
58 import cog
59 cog.out("typedef etl::generic_pool<")
60 cog.out("etl::largest<")
61 for n in range(1, int(NTypes)):
62 cog.out("T%s, " % n)
63 cog.outl("T%s>::size," % int(NTypes))
64 cog.out(" etl::largest<")
65 for n in range(1, int(NTypes)):
66 cog.out("T%s, " % n)
67 cog.outl("T%s>::alignment," % int(NTypes))
68 cog.outl(" MAX_SIZE_> base_t;")
69 ]]]*/
70 /*[[[end]]]*/
71
72 static const size_t MAX_SIZE = MAX_SIZE_;
73
74 //*************************************************************************
76 //*************************************************************************
78 {
79 }
80
81#if ETL_CPP11_NOT_SUPPORTED || ETL_USING_STLPORT
82 //*************************************************************************
84 //*************************************************************************
85 template <typename T>
86 T* create()
87 {
88 /*[[[cog
89 import cog
90 cog.out("ETL_STATIC_ASSERT((etl::is_one_of<T, ")
91 for n in range(1, int(NTypes)):
92 cog.out("T%s, " % n)
93 if n % 16 == 0:
94 cog.outl("")
95 cog.out(" ")
96 cog.outl("T%s>::value), \"Unsupported type\");" % int(NTypes))
97 ]]]*/
98 /*[[[end]]]*/
99
100 return base_t::template create<T>();
101 }
102
103 //*************************************************************************
105 //*************************************************************************
106 template <typename T, typename TP1>
107 T* create(const TP1& p1)
108 {
109 /*[[[cog
110 import cog
111 cog.out("ETL_STATIC_ASSERT((etl::is_one_of<T, ")
112 for n in range(1, int(NTypes)):
113 cog.out("T%s, " % n)
114 if n % 16 == 0:
115 cog.outl("")
116 cog.out(" ")
117 cog.outl("T%s>::value), \"Unsupported type\");" % int(NTypes))
118 ]]]*/
119 /*[[[end]]]*/
120
121 return base_t::template create<T>(p1);
122 }
123
124 //*************************************************************************
126 //*************************************************************************
127 template <typename T, typename TP1, typename TP2>
128 T* create(const TP1& p1, const TP2& p2)
129 {
130 /*[[[cog
131 import cog
132 cog.out("ETL_STATIC_ASSERT((etl::is_one_of<T, ")
133 for n in range(1, int(NTypes)):
134 cog.out("T%s, " % n)
135 if n % 16 == 0:
136 cog.outl("")
137 cog.out(" ")
138 cog.outl("T%s>::value), \"Unsupported type\");" % int(NTypes))
139 ]]]*/
140 /*[[[end]]]*/
141
142 return base_t::template create<T>(p1, p2);
143 }
144
145 //*************************************************************************
147 //*************************************************************************
148 template <typename T, typename TP1, typename TP2, typename TP3>
149 T* create(const TP1& p1, const TP2& p2, const TP3& p3)
150 {
151 /*[[[cog
152 import cog
153 cog.out("ETL_STATIC_ASSERT((etl::is_one_of<T, ")
154 for n in range(1, int(NTypes)):
155 cog.out("T%s, " % n)
156 if n % 16 == 0:
157 cog.outl("")
158 cog.out(" ")
159 cog.outl("T%s>::value), \"Unsupported type\");" % int(NTypes))
160 ]]]*/
161 /*[[[end]]]*/
162
163 return base_t::template create<T>(p1, p2, p3);
164 }
165
166 //*************************************************************************
168 //*************************************************************************
169 template <typename T, typename TP1, typename TP2, typename TP3, typename TP4>
170 T* create(const TP1& p1, const TP2& p2, const TP3& p3, const TP4& p4)
171 {
172 /*[[[cog
173 import cog
174 cog.out("ETL_STATIC_ASSERT((etl::is_one_of<T, ")
175 for n in range(1, int(NTypes)):
176 cog.out("T%s, " % n)
177 if n % 16 == 0:
178 cog.outl("")
179 cog.out(" ")
180 cog.outl("T%s>::value), \"Unsupported type\");" % int(NTypes))
181 ]]]*/
182 /*[[[end]]]*/
183
184 return base_t::template create<T>(p1, p2, p3, p4);
185 }
186#else
187 //*************************************************************************
189 //*************************************************************************
190 template <typename T, typename... Args>
191 T* create(Args && ... args)
192 {
193 /*[[[cog
194 import cog
195 cog.out("ETL_STATIC_ASSERT((etl::is_one_of<T, ")
196 for n in range(1, int(NTypes)):
197 cog.out("T%s, " % n)
198 if n % 16 == 0:
199 cog.outl("")
200 cog.out(" ")
201 cog.outl("T%s>::value), \"Unsupported type\");" % int(NTypes))
202 ]]]*/
203 /*[[[end]]]*/
204
205 return base_t::template create<T>(etl::forward<Args>(args)...);
206 }
207#endif
208
209 //*************************************************************************
211 //*************************************************************************
212 template <typename T>
213 void destroy(const T* const p)
214 {
215 /*[[[cog
216 import cog
217 cog.out("ETL_STATIC_ASSERT((etl::is_one_of<T, ")
218 for n in range(1, int(NTypes)):
219 cog.out("T%s, " % n)
220 if n % 16 == 0:
221 cog.outl("")
222 cog.out(" ")
223 cog.outl("T%s>::value ||" % int(NTypes))
224
225 for n in range(1, int(NTypes)):
226 cog.outl(" etl::is_base_of<T, T%s>::value ||" % n)
227 cog.outl(" etl::is_base_of<T, T%s>::value), \"Invalid type\");" % int(NTypes))
228
229 ]]]*/
230 /*[[[end]]]*/
231
232 base_t::destroy(p);
233 }
234
235 //*************************************************************************
237 //*************************************************************************
238 size_t max_size() const
239 {
240 return MAX_SIZE;
241 }
242
243private:
244
245 variant_pool(const variant_pool&) ETL_DELETE;
246 variant_pool& operator=(const variant_pool&) ETL_DELETE;
247};
248
249//***************************************************************************
250/*[[[cog
251import cog
252cog.outl("template <typename T1,")
253for n in range(2, int(NTypes)):
254 cog.outl(" typename T%s = void," % n)
255cog.outl(" typename T%s = void>" % int(NTypes))
256cog.outl("class variant_pool_ext")
257cog.out(" : public etl::generic_pool_ext<")
258cog.out("etl::largest<")
259for n in range(1, int(NTypes)):
260 cog.out("T%s, " % n)
261cog.outl("T%s>::size," % int(NTypes))
262cog.out(" etl::largest<")
263for n in range(1, int(NTypes)):
264 cog.out("T%s, " % n)
265cog.outl("T%s>::alignment>" % int(NTypes))
266]]]*/
267/*[[[end]]]*/
268{
269public:
270
271 /*[[[cog
272 import cog
273 cog.out("typedef etl::generic_pool_ext<")
274 cog.out("etl::largest<")
275 for n in range(1, int(NTypes)):
276 cog.out("T%s, " % n)
277 cog.outl("T%s>::size," % int(NTypes))
278 cog.out(" etl::largest<")
279 for n in range(1, int(NTypes)):
280 cog.out("T%s, " % n)
281 cog.outl("T%s>::alignment> base_t;" % int(NTypes))
282 ]]]*/
283 /*[[[end]]]*/
284
285 //*************************************************************************
287 //*************************************************************************
288 variant_pool_ext(typename base_t::element * buffer, size_t size)
289 : base_t(buffer, size)
290 {
291 }
292
293#if ETL_CPP11_NOT_SUPPORTED || ETL_USING_STLPORT
294 //*************************************************************************
296 //*************************************************************************
297 template <typename T>
298 T* create()
299 {
300 /*[[[cog
301 import cog
302 cog.out("ETL_STATIC_ASSERT((etl::is_one_of<T, ")
303 for n in range(1, int(NTypes)):
304 cog.out("T%s, " % n)
305 if n % 16 == 0:
306 cog.outl("")
307 cog.out(" ")
308 cog.outl("T%s>::value), \"Unsupported type\");" % int(NTypes))
309 ]]]*/
310 /*[[[end]]]*/
311
312 return base_t::template create<T>();
313 }
314
315 //*************************************************************************
317 //*************************************************************************
318 template <typename T, typename TP1>
319 T* create(const TP1& p1)
320 {
321 /*[[[cog
322 import cog
323 cog.out("ETL_STATIC_ASSERT((etl::is_one_of<T, ")
324 for n in range(1, int(NTypes)):
325 cog.out("T%s, " % n)
326 if n % 16 == 0:
327 cog.outl("")
328 cog.out(" ")
329 cog.outl("T%s>::value), \"Unsupported type\");" % int(NTypes))
330 ]]]*/
331 /*[[[end]]]*/
332
333 return base_t::template create<T>(p1);
334 }
335
336 //*************************************************************************
338 //*************************************************************************
339 template <typename T, typename TP1, typename TP2>
340 T* create(const TP1& p1, const TP2& p2)
341 {
342 /*[[[cog
343 import cog
344 cog.out("ETL_STATIC_ASSERT((etl::is_one_of<T, ")
345 for n in range(1, int(NTypes)):
346 cog.out("T%s, " % n)
347 if n % 16 == 0:
348 cog.outl("")
349 cog.out(" ")
350 cog.outl("T%s>::value), \"Unsupported type\");" % int(NTypes))
351 ]]]*/
352 /*[[[end]]]*/
353
354 return base_t::template create<T>(p1, p2);
355 }
356
357 //*************************************************************************
359 //*************************************************************************
360 template <typename T, typename TP1, typename TP2, typename TP3>
361 T* create(const TP1& p1, const TP2& p2, const TP3& p3)
362 {
363 /*[[[cog
364 import cog
365 cog.out("ETL_STATIC_ASSERT((etl::is_one_of<T, ")
366 for n in range(1, int(NTypes)):
367 cog.out("T%s, " % n)
368 if n % 16 == 0:
369 cog.outl("")
370 cog.out(" ")
371 cog.outl("T%s>::value), \"Unsupported type\");" % int(NTypes))
372 ]]]*/
373 /*[[[end]]]*/
374
375 return base_t::template create<T>(p1, p2, p3);
376 }
377
378 //*************************************************************************
380 //*************************************************************************
381 template <typename T, typename TP1, typename TP2, typename TP3, typename TP4>
382 T* create(const TP1& p1, const TP2& p2, const TP3& p3, const TP4& p4)
383 {
384 /*[[[cog
385 import cog
386 cog.out("ETL_STATIC_ASSERT((etl::is_one_of<T, ")
387 for n in range(1, int(NTypes)):
388 cog.out("T%s, " % n)
389 if n % 16 == 0:
390 cog.outl("")
391 cog.out(" ")
392 cog.outl("T%s>::value), \"Unsupported type\");" % int(NTypes))
393 ]]]*/
394 /*[[[end]]]*/
395
396 return base_t::template create<T>(p1, p2, p3, p4);
397 }
398#else
399 //*************************************************************************
401 //*************************************************************************
402 template <typename T, typename... Args>
403 T* create(Args && ... args)
404 {
405 /*[[[cog
406 import cog
407 cog.out("ETL_STATIC_ASSERT((etl::is_one_of<T, ")
408 for n in range(1, int(NTypes)):
409 cog.out("T%s, " % n)
410 if n % 16 == 0:
411 cog.outl("")
412 cog.out(" ")
413 cog.outl("T%s>::value), \"Unsupported type\");" % int(NTypes))
414 ]]]*/
415 /*[[[end]]]*/
416
417 return base_t::template create<T>(etl::forward<Args>(args)...);
418 }
419#endif
420
421 //*************************************************************************
423 //*************************************************************************
424 template <typename T>
425 void destroy(const T* const p)
426 {
427 /*[[[cog
428 import cog
429 cog.out("ETL_STATIC_ASSERT((etl::is_one_of<T, ")
430 for n in range(1, int(NTypes)):
431 cog.out("T%s, " % n)
432 if n % 16 == 0:
433 cog.outl("")
434 cog.out(" ")
435 cog.outl("T%s>::value ||" % int(NTypes))
436
437 for n in range(1, int(NTypes)):
438 cog.outl(" etl::is_base_of<T, T%s>::value ||" % n)
439 cog.outl(" etl::is_base_of<T, T%s>::value), \"Invalid type\");" % int(NTypes))
440
441 ]]]*/
442 /*[[[end]]]*/
443
444 base_t::destroy(p);
445 }
446
447 //*************************************************************************
449 //*************************************************************************
450 size_t max_size() const
451 {
452 return base_t::max_size();
453 }
454
455private:
456
457 variant_pool_ext(const variant_pool_ext&) ETL_DELETE;
458 variant_pool_ext& operator=(const variant_pool_ext&) ETL_DELETE;
459};
Definition variant_pool_cpp03.h:200
Definition variant_pool_cpp03.h:55
ETL_CONSTEXPR TContainer::size_type size(const TContainer &container)
Definition iterator.h:1192