@@ -101,8 +101,7 @@ template <class T, class Context> struct MappingContextTraits {
101
101
// / io.enumCase(value, "green", cGreen);
102
102
// / }
103
103
// / };
104
- template <typename T>
105
- struct ScalarEnumerationTraits {
104
+ template <typename T, typename Enable = void > struct ScalarEnumerationTraits {
106
105
// Must provide:
107
106
// static void enumeration(IO &io, T &value);
108
107
};
@@ -118,8 +117,7 @@ struct ScalarEnumerationTraits {
118
117
// / io.bitSetCase(value, "round", flagRound);
119
118
// / }
120
119
// / };
121
- template <typename T>
122
- struct ScalarBitSetTraits {
120
+ template <typename T, typename Enable = void > struct ScalarBitSetTraits {
123
121
// Must provide:
124
122
// static void bitset(IO &io, T &value);
125
123
};
@@ -145,8 +143,7 @@ enum class QuotingType { None, Single, Double };
145
143
// / }
146
144
// / static QuotingType mustQuote(StringRef) { return QuotingType::Single; }
147
145
// / };
148
- template <typename T>
149
- struct ScalarTraits {
146
+ template <typename T, typename Enable = void > struct ScalarTraits {
150
147
// Must provide:
151
148
//
152
149
// Function to write the value as a string:
@@ -980,7 +977,7 @@ yamlize(IO &io, T &Val, bool, EmptyContext &Ctx) {
980
977
bool DoClear;
981
978
if ( io.beginBitSetScalar (DoClear) ) {
982
979
if ( DoClear )
983
- Val = static_cast <T>( 0 );
980
+ Val = T ( );
984
981
ScalarBitSetTraits<T>::bitset (io, Val);
985
982
io.endBitSetScalar ();
986
983
}
@@ -1245,12 +1242,14 @@ struct ScalarTraits<double> {
1245
1242
static QuotingType mustQuote (StringRef) { return QuotingType::None; }
1246
1243
};
1247
1244
1248
- // For endian types, we just use the existing ScalarTraits for the underlying
1249
- // type. This way endian aware types are supported whenever a ScalarTraits
1250
- // is defined for the underlying type.
1245
+ // For endian types, we use existing scalar Traits class for the underlying
1246
+ // type. This way endian aware types are supported whenever the traits are
1247
+ // defined for the underlying type.
1251
1248
template <typename value_type, support::endianness endian, size_t alignment>
1252
- struct ScalarTraits <support::detail::packed_endian_specific_integral<
1253
- value_type, endian, alignment>> {
1249
+ struct ScalarTraits <
1250
+ support::detail::packed_endian_specific_integral<value_type, endian,
1251
+ alignment>,
1252
+ typename std::enable_if<has_ScalarTraits<value_type>::value>::type> {
1254
1253
using endian_type =
1255
1254
support::detail::packed_endian_specific_integral<value_type, endian,
1256
1255
alignment>;
@@ -1271,6 +1270,38 @@ struct ScalarTraits<support::detail::packed_endian_specific_integral<
1271
1270
}
1272
1271
};
1273
1272
1273
+ template <typename value_type, support::endianness endian, size_t alignment>
1274
+ struct ScalarEnumerationTraits <
1275
+ support::detail::packed_endian_specific_integral<value_type, endian,
1276
+ alignment>,
1277
+ typename std::enable_if<
1278
+ has_ScalarEnumerationTraits<value_type>::value>::type> {
1279
+ using endian_type =
1280
+ support::detail::packed_endian_specific_integral<value_type, endian,
1281
+ alignment>;
1282
+
1283
+ static void enumeration (IO &io, endian_type &E) {
1284
+ value_type V = E;
1285
+ ScalarEnumerationTraits<value_type>::enumeration (io, V);
1286
+ E = V;
1287
+ }
1288
+ };
1289
+
1290
+ template <typename value_type, support::endianness endian, size_t alignment>
1291
+ struct ScalarBitSetTraits <
1292
+ support::detail::packed_endian_specific_integral<value_type, endian,
1293
+ alignment>,
1294
+ typename std::enable_if<has_ScalarBitSetTraits<value_type>::value>::type> {
1295
+ using endian_type =
1296
+ support::detail::packed_endian_specific_integral<value_type, endian,
1297
+ alignment>;
1298
+ static void bitset (IO &io, endian_type &E) {
1299
+ value_type V = E;
1300
+ ScalarBitSetTraits<value_type>::bitset (io, V);
1301
+ E = V;
1302
+ }
1303
+ };
1304
+
1274
1305
// Utility for use within MappingTraits<>::mapping() method
1275
1306
// to [de]normalize an object for use with YAML conversion.
1276
1307
template <typename TNorm, typename TFinal>
0 commit comments