diff --git a/include/etl/generators/type_traits_generator.h b/include/etl/generators/type_traits_generator.h index c94b90e77..f7c5580aa 100644 --- a/include/etl/generators/type_traits_generator.h +++ b/include/etl/generators/type_traits_generator.h @@ -1642,6 +1642,11 @@ typedef integral_constant true_type; template using is_constructible = std::is_constructible; + //********************************************* + // is_default_constructible + template + using is_default_constructible = std::is_default_constructible; + //********************************************* // is_copy_constructible template @@ -1879,6 +1884,14 @@ typedef integral_constant true_type; }; #endif + //********************************************* + // is_default_constructible + template + struct is_default_constructible : etl::false_type { }; + + template + struct is_default_constructible> : etl::true_type { }; + //********************************************* // is_copy_constructible template ::value || etl::is_pointer::value> diff --git a/include/etl/type_traits.h b/include/etl/type_traits.h index 816953d57..f64a5b4df 100644 --- a/include/etl/type_traits.h +++ b/include/etl/type_traits.h @@ -1635,6 +1635,11 @@ typedef integral_constant true_type; template using is_constructible = std::is_constructible; + //********************************************* + // is_default_constructible + template + using is_default_constructible = std::is_default_constructible; + //********************************************* // is_copy_constructible template @@ -1872,6 +1877,14 @@ typedef integral_constant true_type; }; #endif + //********************************************* + // is_default_constructible + template + struct is_default_constructible : etl::false_type { }; + + template + struct is_default_constructible> : etl::true_type { }; + //********************************************* // is_copy_constructible template ::value || etl::is_pointer::value> diff --git a/test/test_type_traits.cpp b/test/test_type_traits.cpp index 706c1dfb2..af5feacab 100644 --- a/test/test_type_traits.cpp +++ b/test/test_type_traits.cpp @@ -111,6 +111,17 @@ namespace MoveableCopyable(const MoveableCopyable&) {} MoveableCopyable& operator =(const MoveableCopyable&) { return *this; } }; + + //********************************************* + struct NotDefaultConstructible + { + NotDefaultConstructible() = delete; + NotDefaultConstructible(const NotDefaultConstructible&) noexcept {} + NotDefaultConstructible& operator =(const NotDefaultConstructible&) noexcept { return *this; } + + NotDefaultConstructible(NotDefaultConstructible&&) = delete; + NotDefaultConstructible& operator =(NotDefaultConstructible&) = delete; + }; } // Definitions for when the STL and compiler built-ins are not available. @@ -1137,10 +1148,28 @@ namespace CHECK((etl::is_constructible_v) == (std::is_constructible_v)); CHECK((etl::is_constructible_v) == (std::is_constructible_v)); CHECK((etl::is_constructible_v) == (std::is_constructible_v)); + CHECK((etl::is_constructible_v) == (std::is_constructible_v)); #else CHECK((etl::is_constructible::value) == (std::is_constructible::value)); CHECK((etl::is_constructible::value) == (std::is_constructible::value)); CHECK((etl::is_constructible::value) == (std::is_constructible::value)); + CHECK((etl::is_constructible::value) == (std::is_constructible::value)); +#endif + } + + //************************************************************************* + TEST(test_is_default_constructible) + { +#if ETL_USING_CPP17 + CHECK((etl::is_default_constructible_v) == (std::is_default_constructible_v)); + CHECK((etl::is_default_constructible_v) == (std::is_default_constructible_v)); + CHECK((etl::is_default_constructible_v) == (std::is_default_constructible_v)); + CHECK((etl::is_default_constructible_v) == (std::is_default_constructible_v)); +#else + CHECK((etl::is_default_constructible::value) == (std::is_default_constructible::value)); + CHECK((etl::is_default_constructible::value) == (std::is_default_constructible::value)); + CHECK((etl::is_default_constructible::value) == (std::is_default_constructible::value)); + CHECK((etl::is_default_constructible::value) == (std::is_default_constructible::value)); #endif }