diff --git a/include/etl/generators/type_traits_generator.h b/include/etl/generators/type_traits_generator.h index 42189f43..373b5d0e 100644 --- a/include/etl/generators/type_traits_generator.h +++ b/include/etl/generators/type_traits_generator.h @@ -872,6 +872,42 @@ namespace etl public: static ETL_CONSTANT bool value = decltype(test(0))::value; }; +#else + namespace private_type_traits + { + typedef char yes; + struct no { char dummy[2]; }; + + template + struct is_convertible_impl + { + static yes test(TTo); + static no test(...); + static TFrom make(); + static const bool value = (sizeof(test(make())) == sizeof(yes)); + }; + + template + struct is_convertible_impl + { + static const bool value = false; + }; + + template + struct is_convertible_impl + { + static const bool value = false; + }; + + template <> + struct is_convertible_impl + { + static const bool value = true; + }; + } + + template + struct is_convertible : etl::bool_constant::value> {}; #endif #if ETL_USING_CPP17 @@ -1420,6 +1456,42 @@ typedef integral_constant true_type; public: static ETL_CONSTANT bool value = decltype(test(0))::value; }; +#else + namespace private_type_traits + { + typedef char yes; + struct no { char dummy[2]; }; + + template + struct is_convertible_impl + { + static yes test(TTo); + static no test(...); + static TFrom make(); + static const bool value = (sizeof(test(make())) == sizeof(yes)); + }; + + template + struct is_convertible_impl + { + static const bool value = false; + }; + + template + struct is_convertible_impl + { + static const bool value = false; + }; + + template <> + struct is_convertible_impl + { + static const bool value = true; + }; + } + + template + struct is_convertible : etl::bool_constant::value> {}; #endif #if ETL_USING_CPP17 @@ -1556,17 +1628,17 @@ typedef integral_constant true_type; cog.outl("/// Template to determine if a type is one of a specified list.") cog.outl("///\\ingroup types") cog.outl("template " % IsOneOf) + cog.out(" ") + cog.outl(" typename T%s = void>" % IsOneOf) cog.outl("struct is_one_of") cog.outl("{") - cog.outl(" static const bool value = ") + cog.outl(" static const bool value =") for n in range(1, int(IsOneOf)): cog.outl(" etl::is_same::value ||" % n) cog.outl(" etl::is_same::value;" % IsOneOf)