diff --git a/include/etl/generators/type_traits_generator.h b/include/etl/generators/type_traits_generator.h index b7e16d8d..491ca081 100644 --- a/include/etl/generators/type_traits_generator.h +++ b/include/etl/generators/type_traits_generator.h @@ -714,7 +714,7 @@ namespace etl //*************************************************************************** /// is_enum ///\ingroup type_traits - /// Implemented by checking if type is convertable to an integer thru static_cast + /// Implemented by checking if type is convertible to an integer through static_cast namespace private_type_traits { @@ -1988,13 +1988,40 @@ namespace etl }; #if ETL_USING_CPP11 + //*************************************************************************** + /// is_constructible + namespace private_type_traits + { + template + struct is_constructible_ : etl::false_type {}; + + template + struct is_constructible_()...))>, T, Args...> : etl::true_type {}; + }; + + //********************************************* // is_constructible - template - struct is_constructible : public etl::bool_constant::value || etl::is_pointer::value> - { - }; -#endif + template + using is_constructible = private_type_traits::is_constructible_, T, Args...>; + + //********************************************* + // is_copy_constructible + template struct is_copy_constructible : public is_constructible::type>::type>{}; + template <> struct is_copy_constructible : public false_type{}; + template <> struct is_copy_constructible : public false_type{}; + template <> struct is_copy_constructible : public false_type{}; + template <> struct is_copy_constructible : public false_type{}; + + //********************************************* + // is_move_constructible + template struct is_move_constructible: public is_constructible::type>{}; + template <> struct is_move_constructible : public false_type{}; + template <> struct is_move_constructible : public false_type{}; + template <> struct is_move_constructible : public false_type{}; + template <> struct is_move_constructible : public false_type{}; + +#else //********************************************* // is_copy_constructible @@ -2009,6 +2036,7 @@ namespace etl struct is_move_constructible : public etl::bool_constant::value || etl::is_pointer::value> { }; +#endif //********************************************* // is_trivially_constructible diff --git a/include/etl/type_traits.h b/include/etl/type_traits.h index 3ef8d979..80f2152c 100644 --- a/include/etl/type_traits.h +++ b/include/etl/type_traits.h @@ -702,7 +702,7 @@ namespace etl //*************************************************************************** /// is_enum ///\ingroup type_traits - /// Implemented by checking if type is convertable to an integer thru static_cast + /// Implemented by checking if type is convertible to an integer through static_cast namespace private_type_traits { @@ -1981,13 +1981,40 @@ namespace etl }; #if ETL_USING_CPP11 + //*************************************************************************** + /// is_constructible + namespace private_type_traits + { + template + struct is_constructible_ : etl::false_type {}; + + template + struct is_constructible_()...))>, T, Args...> : etl::true_type {}; + }; + + //********************************************* // is_constructible - template - struct is_constructible : public etl::bool_constant::value || etl::is_pointer::value> - { - }; -#endif + template + using is_constructible = private_type_traits::is_constructible_, T, Args...>; + + //********************************************* + // is_copy_constructible + template struct is_copy_constructible : public is_constructible::type>::type>{}; + template <> struct is_copy_constructible : public false_type{}; + template <> struct is_copy_constructible : public false_type{}; + template <> struct is_copy_constructible : public false_type{}; + template <> struct is_copy_constructible : public false_type{}; + + //********************************************* + // is_move_constructible + template struct is_move_constructible: public is_constructible::type>{}; + template <> struct is_move_constructible : public false_type{}; + template <> struct is_move_constructible : public false_type{}; + template <> struct is_move_constructible : public false_type{}; + template <> struct is_move_constructible : public false_type{}; + +#else //********************************************* // is_copy_constructible @@ -2002,6 +2029,7 @@ namespace etl struct is_move_constructible : public etl::bool_constant::value || etl::is_pointer::value> { }; +#endif //********************************************* // is_trivially_constructible diff --git a/test/test_type_traits.cpp b/test/test_type_traits.cpp index 83848757..363d59d9 100644 --- a/test/test_type_traits.cpp +++ b/test/test_type_traits.cpp @@ -127,11 +127,6 @@ struct etl::is_assignable : public etl::true_type { }; -template <> -struct etl::is_constructible : public etl::true_type -{ -}; - template <> struct etl::is_copy_constructible : public etl::true_type { @@ -148,11 +143,6 @@ struct etl::is_assignable : public etl::true_type { }; -template <> -struct etl::is_constructible : public etl::true_type -{ -}; - template <> struct etl::is_copy_constructible : public etl::false_type { @@ -169,11 +159,6 @@ struct etl::is_assignable : public etl::true { }; -template <> -struct etl::is_constructible : public etl::true_type -{ -}; - template <> struct etl::is_copy_constructible : public etl::true_type {