Embedded Template Library 1.0
Loading...
Searching...
No Matches
largest_type_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/*[[[cog
34import cog
35cog.outl("//***************************************************************************")
36cog.outl("/// Template to determine the largest type and size.")
37cog.outl("/// Supports up to %s types." % NTypes)
38cog.outl("/// Defines 'type' which is the type of the largest parameter.")
39cog.outl("/// Defines 'size' which is the size of the largest parameter.")
40cog.outl("///\\ingroup largest")
41cog.outl("//***************************************************************************")
42cog.out("template <typename T1, ")
43for n in range(2, int(NTypes)):
44 cog.out("typename T%s = void, " % n)
45 if n % 4 == 0:
46 cog.outl("")
47 cog.out(" ")
48cog.outl("typename T%s = void>" % int(NTypes))
49cog.outl("struct largest_type")
50cog.outl("{")
51cog.outl(" // Define 'largest_other' as 'largest_type' with all but the first parameter. ")
52cog.out(" typedef typename largest_type<")
53for n in range(2, int(NTypes)):
54 cog.out("T%s, " % n)
55 if n % 16 == 0:
56 cog.outl("")
57 cog.out(" ")
58cog.outl("T%s>::type largest_other;" % int(NTypes))
59cog.outl("")
60cog.outl(" // Set 'type' to be the largest of the first parameter and any of the others.")
61cog.outl(" // This is recursive.")
62cog.outl(" typedef typename etl::conditional<(sizeof(T1) > sizeof(largest_other)), // Boolean")
63cog.outl(" T1, // TrueType")
64cog.outl(" largest_other> // FalseType")
65cog.outl(" ::type type; // The largest type of the two.")
66cog.outl("")
67cog.outl(" // The size of the largest type.")
68cog.outl(" enum")
69cog.outl(" {")
70cog.outl(" size = sizeof(type)")
71cog.outl(" };")
72cog.outl("};")
73cog.outl("")
74cog.outl("//***************************************************************************")
75cog.outl("// Specialisation for one template parameter.")
76cog.outl("//***************************************************************************")
77cog.outl("template <typename T1>")
78cog.out("struct largest_type<T1, ")
79for n in range(2, int(NTypes)):
80 cog.out("void, ")
81 if n % 8 == 0:
82 cog.outl("")
83 cog.out(" ")
84cog.outl("void>")
85cog.outl("{")
86cog.outl(" typedef T1 type;")
87cog.outl("")
88cog.outl(" enum")
89cog.outl(" {")
90cog.outl(" size = sizeof(type)")
91cog.outl(" };")
92cog.outl("};")
93]]]*/
94/*[[[end]]]*/