Embedded Template Library
1.0
Loading...
Searching...
No Matches
largest_type_cpp03_generator.h
1
/******************************************************************************
2
The MIT License(MIT)
3
4
Embedded Template Library.
5
https://github.com/ETLCPP/etl
6
https://www.etlcpp.com
7
8
Copyright(c) 2026 John Wellbelove
9
10
Permission is hereby granted, free of charge, to any person obtaining a copy
11
of this software and associated documentation files(the "Software"), to deal
12
in the Software without restriction, including without limitation the rights
13
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
14
copies of the Software, and to permit persons to whom the Software is
15
furnished to do so, subject to the following conditions :
16
17
The above copyright notice and this permission notice shall be included in all
18
copies or substantial portions of the Software.
19
20
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
23
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
SOFTWARE.
27
******************************************************************************/
28
29
//***************************************************************************
30
// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.
31
//***************************************************************************
32
33
/*[[[cog
34
import cog
35
cog.outl("//***************************************************************************")
36
cog.outl("/// Template to determine the largest type and size.")
37
cog.outl("/// Supports up to %s types." % NTypes)
38
cog.outl("/// Defines 'type' which is the type of the largest parameter.")
39
cog.outl("/// Defines 'size' which is the size of the largest parameter.")
40
cog.outl("///\\ingroup largest")
41
cog.outl("//***************************************************************************")
42
cog.out("template <typename T1, ")
43
for 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(" ")
48
cog.outl("typename T%s = void>" % int(NTypes))
49
cog.outl("struct largest_type")
50
cog.outl("{")
51
cog.outl(" // Define 'largest_other' as 'largest_type' with all but the first parameter. ")
52
cog.out(" typedef typename largest_type<")
53
for n in range(2, int(NTypes)):
54
cog.out("T%s, " % n)
55
if n % 16 == 0:
56
cog.outl("")
57
cog.out(" ")
58
cog.outl("T%s>::type largest_other;" % int(NTypes))
59
cog.outl("")
60
cog.outl(" // Set 'type' to be the largest of the first parameter and any of the others.")
61
cog.outl(" // This is recursive.")
62
cog.outl(" typedef typename etl::conditional<(sizeof(T1) > sizeof(largest_other)), // Boolean")
63
cog.outl(" T1, // TrueType")
64
cog.outl(" largest_other> // FalseType")
65
cog.outl(" ::type type; // The largest type of the two.")
66
cog.outl("")
67
cog.outl(" // The size of the largest type.")
68
cog.outl(" enum")
69
cog.outl(" {")
70
cog.outl(" size = sizeof(type)")
71
cog.outl(" };")
72
cog.outl("};")
73
cog.outl("")
74
cog.outl("//***************************************************************************")
75
cog.outl("// Specialisation for one template parameter.")
76
cog.outl("//***************************************************************************")
77
cog.outl("template <typename T1>")
78
cog.out("struct largest_type<T1, ")
79
for n in range(2, int(NTypes)):
80
cog.out("void, ")
81
if n % 8 == 0:
82
cog.outl("")
83
cog.out(" ")
84
cog.outl("void>")
85
cog.outl("{")
86
cog.outl(" typedef T1 type;")
87
cog.outl("")
88
cog.outl(" enum")
89
cog.outl(" {")
90
cog.outl(" size = sizeof(type)")
91
cog.outl(" };")
92
cog.outl("};")
93
]]]*/
94
/*[[[end]]]*/
include
etl
generators
largest_type_cpp03_generator.h
Generated on
for Embedded Template Library by
1.15.0