Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
largest.h
00001 ///\file 00002 00003 /****************************************************************************** 00004 The MIT License(MIT) 00005 00006 Embedded Template Library. 00007 https://github.com/ETLCPP/etl 00008 https://www.etlcpp.com 00009 00010 Copyright(c) 2014 jwellbelove 00011 00012 Permission is hereby granted, free of charge, to any person obtaining a copy 00013 of this software and associated documentation files(the "Software"), to deal 00014 in the Software without restriction, including without limitation the rights 00015 to use, copy, modify, merge, publish, distribute, sublicense, and / or sell 00016 copies of the Software, and to permit persons to whom the Software is 00017 furnished to do so, subject to the following conditions : 00018 00019 The above copyright notice and this permission notice shall be included in all 00020 copies or substantial portions of the Software. 00021 00022 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00023 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00024 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE 00025 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00026 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00027 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 00028 SOFTWARE. 00029 ******************************************************************************/ 00030 00031 #if 0 00032 #error THIS HEADER IS A GENERATOR. DO NOT INCLUDE. 00033 #endif 00034 00035 //*************************************************************************** 00036 // This file has been auto generated. Do not edit this file. 00037 //*************************************************************************** 00038 00039 //*************************************************************************** 00040 // To generate to header file, run this at the command line. 00041 // Note: You will need Python and COG installed. 00042 // 00043 // python -m cogapp -d -e -olargest.h -DNTypes=<n> largest_generator.h 00044 // Where <n> is the number of types to support. 00045 // 00046 // e.g. 00047 // To generate handlers for up to 16 types... 00048 // python -m cogapp -d -e -olargest.h -DNTypes=16 largest_generator.h 00049 // 00050 // See generate.bat 00051 //*************************************************************************** 00052 00053 #ifndef __ETL_LARGEST__ 00054 #define __ETL_LARGEST__ 00055 00056 ///\defgroup largest largest 00057 ///\ingroup utilities 00058 00059 #include "platform.h " 00060 #include "type_traits.h " 00061 #include "smallest.h " 00062 #include "static_assert.h" 00063 00064 namespace etl 00065 { 00066 //*************************************************************************** 00067 /// Template to determine the largest type and size. 00068 /// Supports up to 16 types. 00069 /// Defines 'value_type' which is the type of the largest parameter. 00070 /// Defines 'size' which is the size of the largest parameter. 00071 ///\ingroup largest 00072 //*************************************************************************** 00073 template <typename T1, typename T2 = void, typename T3 = void, typename T4 = void, 00074 typename T5 = void, typename T6 = void, typename T7 = void, typename T8 = void, 00075 typename T9 = void, typename T10 = void, typename T11 = void, typename T12 = void, 00076 typename T13 = void, typename T14 = void, typename T15 = void, typename T16 = void> 00077 struct largest_type 00078 { 00079 // Define 'largest_other' as 'largest_type' with all but the first parameter. 00080 typedef typename largest_type<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::type largest_other; 00081 00082 // Set 'type' to be the largest of the first parameter and any of the others. 00083 // This is recursive. 00084 typedef typename etl::conditional<(sizeof(T1) > sizeof(largest_other)), // Boolean 00085 T1, // TrueType 00086 largest_other> // FalseType 00087 ::type type; // The largest type of the two. 00088 00089 // The size of the largest type. 00090 enum 00091 { 00092 size = sizeof(type) 00093 }; 00094 }; 00095 00096 //*************************************************************************** 00097 // Specialisation for one template parameter. 00098 //*************************************************************************** 00099 template <typename T1> 00100 struct largest_type<T1, void, void, void, void, void, void, void, 00101 void, void, void, void, void, void, void, void> 00102 { 00103 typedef T1 type; 00104 00105 enum 00106 { 00107 size = sizeof(type) 00108 }; 00109 }; 00110 00111 //*************************************************************************** 00112 /// Template to determine the largest alignment. 00113 /// Supports up to 16 types. 00114 /// Defines <b>value</b> which is the largest alignment of all the parameters. 00115 ///\ingroup largest 00116 //*************************************************************************** 00117 template <typename T1, typename T2 = void, typename T3 = void, typename T4 = void, 00118 typename T5 = void, typename T6 = void, typename T7 = void, typename T8 = void, 00119 typename T9 = void, typename T10 = void, typename T11 = void, typename T12 = void, 00120 typename T13 = void, typename T14 = void, typename T15 = void, typename T16 = void> 00121 struct largest_alignment 00122 { 00123 // Define 'largest_other' as 'largest_type' with all but the first parameter. 00124 typedef typename largest_alignment<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::type largest_other; 00125 00126 // Set 'type' to be the largest of the first parameter and any of the others. 00127 // This is recursive. 00128 typedef typename etl::conditional<(etl::alignment_of<T1>::value > etl::alignment_of<largest_other>::value), // Boolean 00129 T1, // TrueType 00130 largest_other> // FalseType 00131 ::type type; // The largest type of the two. 00132 00133 // The largest alignment. 00134 enum 00135 { 00136 value = etl::alignment_of<type>::value 00137 }; 00138 }; 00139 00140 //*************************************************************************** 00141 // Specialisation for one template parameter. 00142 //*************************************************************************** 00143 template <typename T1> 00144 struct largest_alignment<T1, void, void, void, void, void, void, void, 00145 void, void, void, void, void, void, void, void> 00146 { 00147 typedef T1 type; 00148 00149 enum 00150 { 00151 value = etl::alignment_of<type>::value 00152 }; 00153 }; 00154 00155 //*************************************************************************** 00156 /// Defines a type that is as larger or larger than the specified type. 00157 /// Will return the specified type is there is not a larger type. 00158 ///\ingroup largest 00159 //*************************************************************************** 00160 template <typename T> 00161 struct larger_int_type 00162 { 00163 STATIC_ASSERT(etl::is_integral<T>::value, "Must be an integral type"); 00164 00165 typedef typename etl::smallest_int_for_bits<etl::integral_limits<typename etl::make_signed<T>::type>::bits + 1>::type type; 00166 }; 00167 00168 //*************************************************************************** 00169 /// Defines a type that is as larger or larger than the specified type. 00170 /// Will return the specified type is there is not a larger type. 00171 ///\ingroup largest 00172 //*************************************************************************** 00173 template <typename T> 00174 struct larger_uint_type 00175 { 00176 STATIC_ASSERT(etl::is_integral<T>::value, "Must be an integral type"); 00177 00178 typedef typename etl::smallest_uint_for_bits<etl::integral_limits<typename etl::make_unsigned<T>::type>::bits + 1>::type type; 00179 }; 00180 00181 //*************************************************************************** 00182 /// Defines a type that is as larger or larger than the specified type. 00183 /// Will return the specified type is there is not a larger type. 00184 /// The returned type will be of the same sign. 00185 ///\ingroup largest 00186 //*************************************************************************** 00187 template <typename T, bool IS_SIGNED = etl::is_signed<T>::value> 00188 struct larger_type; 00189 00190 template <typename T> 00191 struct larger_type<T, false> 00192 { 00193 STATIC_ASSERT(etl::is_integral<T>::value, "Must be an integral type"); 00194 00195 typedef typename etl::smallest_uint_for_bits<etl::integral_limits<T>::bits + 1>::type type; 00196 }; 00197 00198 template <typename T> 00199 struct larger_type<T, true> 00200 { 00201 STATIC_ASSERT(etl::is_integral<T>::value, "Must be an integral type"); 00202 00203 typedef typename etl::smallest_int_for_bits<etl::integral_limits<T>::bits + 1>::type type; 00204 }; 00205 00206 //*************************************************************************** 00207 /// Template to determine the largest type, size and alignment. 00208 /// Supports up to 16 types. 00209 /// Defines <b>value</b> which is the largest type, size and alignment of all the parameters. 00210 ///\ingroup largest 00211 //*************************************************************************** 00212 template <typename T1, typename T2 = void, typename T3 = void, typename T4 = void, 00213 typename T5 = void, typename T6 = void, typename T7 = void, typename T8 = void, 00214 typename T9 = void, typename T10 = void, typename T11 = void, typename T12 = void, 00215 typename T13 = void, typename T14 = void, typename T15 = void, typename T16 = void> 00216 struct largest 00217 { 00218 typedef typename etl::largest_type<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::type type; 00219 00220 enum 00221 { 00222 size = etl::largest_type<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::size, 00223 alignment = etl::largest_alignment<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::value 00224 }; 00225 }; 00226 } 00227 00228 #endif 00229
Generated on Tue Jul 12 2022 14:05:42 by
