diff --git a/.gitignore b/.gitignore index 4c9515dd..72c021e0 100644 --- a/.gitignore +++ b/.gitignore @@ -324,3 +324,4 @@ test/vs2019/Test1 test/vs2019/Test2 test/vs2019/Debug MSVC - Force C++03 test/vs2019/Debug LLVM - No STL +test/vs2019/Debug - No STL diff --git a/include/etl/generators/type_traits_generator.h b/include/etl/generators/type_traits_generator.h index 4716f9ed..9f734c44 100644 --- a/include/etl/generators/type_traits_generator.h +++ b/include/etl/generators/type_traits_generator.h @@ -284,8 +284,8 @@ namespace etl //*************************************************************************** /// is_signed template struct is_signed : false_type {}; - template <> struct is_signed : integral_constant {}; - template <> struct is_signed : public etl::integral_constant(wchar_t(-1) < wchar_t(0))> {}; + template <> struct is_signed : etl::bool_constant<(char(255) < 0)> {}; + template <> struct is_signed : public etl::bool_constant(wchar_t(-1) < wchar_t(0))> {}; template <> struct is_signed : true_type {}; template <> struct is_signed : true_type {}; template <> struct is_signed : true_type {}; @@ -307,9 +307,9 @@ namespace etl /// is_unsigned template struct is_unsigned : false_type {}; template <> struct is_unsigned : true_type {}; - template <> struct is_unsigned : integral_constant 0)> {}; + template <> struct is_unsigned : etl::bool_constant<(char(255) > 0)> {}; template <> struct is_unsigned : true_type {}; - template <> struct is_unsigned : public etl::integral_constant wchar_t(0))> {}; + template <> struct is_unsigned : public etl::bool_constant<(wchar_t(-1) > wchar_t(0))> {}; template <> struct is_unsigned : true_type {}; template <> struct is_unsigned : true_type {}; template <> struct is_unsigned : true_type {}; @@ -360,7 +360,7 @@ namespace etl //*************************************************************************** /// is_arithmetic - template struct is_arithmetic : integral_constant::value || is_floating_point::value> {}; + template struct is_arithmetic : etl::bool_constant::value || is_floating_point::value> {}; #if ETL_CPP17_SUPPORTED template @@ -369,7 +369,7 @@ namespace etl //*************************************************************************** /// is_fundamental - template struct is_fundamental : integral_constant::value || is_void::value> {}; + template struct is_fundamental : etl::bool_constant::value || is_void::value> {}; #if ETL_CPP17_SUPPORTED template @@ -378,7 +378,7 @@ namespace etl //*************************************************************************** /// is_compound - template struct is_compound : integral_constant::value> {}; + template struct is_compound : etl::bool_constant::value> {}; #if ETL_CPP17_SUPPORTED template @@ -445,7 +445,7 @@ namespace etl //*************************************************************************** /// is_pod /// Only fundamental and pointers types are recognised. - template struct is_pod : etl::integral_constant::value || etl::is_pointer::value> {}; + template struct is_pod : etl::bool_constant::value || etl::is_pointer::value> {}; #if ETL_CPP17_SUPPORTED template @@ -644,7 +644,7 @@ namespace etl } template - struct is_class : etl::integral_constant(0)) == 1U> {}; + struct is_class : etl::bool_constant(0)) == 1U> {}; #if ETL_CPP17_SUPPORTED template @@ -711,12 +711,12 @@ namespace etl #if defined(ETL_COMPILER_ARM5) template - struct is_convertible : etl::integral_constant {}; + struct is_convertible : etl::bool_constant<__is_convertible_to(TFrom, TTo)> {}; #else template - struct is_convertible : etl::integral_constant(0))::value && - decltype(private_type_traits::nonvoid_convertible(0))::value) || - (etl::is_void::value && etl::is_void::value)> {}; + struct is_convertible : etl::bool_constant<(decltype(private_type_traits::returnable(0))::value && + decltype(private_type_traits::nonvoid_convertible(0))::value) || + (etl::is_void::value && etl::is_void::value)> {}; #endif #endif @@ -1554,16 +1554,10 @@ namespace etl { }; #else - template ::value || etl::is_pointer::value> - struct is_trivially_constructible; - template - struct is_trivially_constructible : public etl::true_type + struct is_trivially_constructible : public etl::bool_constant::value || etl::is_pointer::value> { }; - - template - struct is_trivially_constructible; #endif //********************************************* @@ -1574,16 +1568,10 @@ namespace etl { }; #else - template ::value || etl::is_pointer::value> - struct is_trivially_copy_constructible; - template - struct is_trivially_copy_constructible : public etl::true_type + struct is_trivially_copy_constructible : public etl::bool_constant::value || etl::is_pointer::value> { }; - - template - struct is_trivially_copy_constructible; #endif //********************************************* @@ -1594,16 +1582,10 @@ namespace etl { }; #else - template ::value || etl::is_pointer::value> - struct is_trivially_destructible; - template - struct is_trivially_destructible : public etl::true_type + struct is_trivially_destructible : public etl::bool_constant::value || etl::is_pointer::value> { }; - - template - struct is_trivially_destructible; #endif //********************************************* @@ -1614,16 +1596,10 @@ namespace etl { }; #else - template ::value || etl::is_pointer::value> - struct is_trivially_copy_assignable; - template - struct is_trivially_copy_assignable : public etl::true_type + struct is_trivially_copy_assignable : public etl::bool_constant::value || etl::is_pointer::value> { }; - - template - struct is_trivially_copy_assignable; #endif //********************************************* @@ -1634,16 +1610,10 @@ namespace etl { }; #else - template ::value || etl::is_pointer::value> - struct is_trivially_copyable; - template - struct is_trivially_copyable : public etl::true_type + struct is_trivially_copyable : public etl::bool_constant::value || etl::is_pointer::value> { }; - - template - struct is_trivially_copyable; #endif #elif defined(ETL_USE_TYPE_TRAITS_BUILTINS) && !defined(ETL_USER_DEFINED_TYPE_TRAITS) diff --git a/include/etl/type_traits.h b/include/etl/type_traits.h index 5ec0db6f..a96a9baf 100644 --- a/include/etl/type_traits.h +++ b/include/etl/type_traits.h @@ -272,8 +272,8 @@ namespace etl //*************************************************************************** /// is_signed template struct is_signed : false_type {}; - template <> struct is_signed : integral_constant {}; - template <> struct is_signed : public etl::integral_constant(wchar_t(-1) < wchar_t(0))> {}; + template <> struct is_signed : etl::bool_constant<(char(255) < 0)> {}; + template <> struct is_signed : public etl::bool_constant(wchar_t(-1) < wchar_t(0))> {}; template <> struct is_signed : true_type {}; template <> struct is_signed : true_type {}; template <> struct is_signed : true_type {}; @@ -295,9 +295,9 @@ namespace etl /// is_unsigned template struct is_unsigned : false_type {}; template <> struct is_unsigned : true_type {}; - template <> struct is_unsigned : integral_constant 0)> {}; + template <> struct is_unsigned : etl::bool_constant<(char(255) > 0)> {}; template <> struct is_unsigned : true_type {}; - template <> struct is_unsigned : public etl::integral_constant wchar_t(0))> {}; + template <> struct is_unsigned : public etl::bool_constant<(wchar_t(-1) > wchar_t(0))> {}; template <> struct is_unsigned : true_type {}; template <> struct is_unsigned : true_type {}; template <> struct is_unsigned : true_type {}; @@ -348,7 +348,7 @@ namespace etl //*************************************************************************** /// is_arithmetic - template struct is_arithmetic : integral_constant::value || is_floating_point::value> {}; + template struct is_arithmetic : etl::bool_constant::value || is_floating_point::value> {}; #if ETL_CPP17_SUPPORTED template @@ -357,7 +357,7 @@ namespace etl //*************************************************************************** /// is_fundamental - template struct is_fundamental : integral_constant::value || is_void::value> {}; + template struct is_fundamental : etl::bool_constant::value || is_void::value> {}; #if ETL_CPP17_SUPPORTED template @@ -366,7 +366,7 @@ namespace etl //*************************************************************************** /// is_compound - template struct is_compound : integral_constant::value> {}; + template struct is_compound : etl::bool_constant::value> {}; #if ETL_CPP17_SUPPORTED template @@ -433,7 +433,7 @@ namespace etl //*************************************************************************** /// is_pod /// Only fundamental and pointers types are recognised. - template struct is_pod : etl::integral_constant::value || etl::is_pointer::value> {}; + template struct is_pod : etl::bool_constant::value || etl::is_pointer::value> {}; #if ETL_CPP17_SUPPORTED template @@ -632,7 +632,7 @@ namespace etl } template - struct is_class : etl::integral_constant(0)) == 1U> {}; + struct is_class : etl::bool_constant(0)) == 1U> {}; #if ETL_CPP17_SUPPORTED template @@ -699,12 +699,12 @@ namespace etl #if defined(ETL_COMPILER_ARM5) template - struct is_convertible : etl::integral_constant {}; + struct is_convertible : etl::bool_constant<__is_convertible_to(TFrom, TTo)> {}; #else template - struct is_convertible : etl::integral_constant(0))::value && - decltype(private_type_traits::nonvoid_convertible(0))::value) || - (etl::is_void::value && etl::is_void::value)> {}; + struct is_convertible : etl::bool_constant<(decltype(private_type_traits::returnable(0))::value && + decltype(private_type_traits::nonvoid_convertible(0))::value) || + (etl::is_void::value && etl::is_void::value)> {}; #endif #endif @@ -1547,16 +1547,10 @@ namespace etl { }; #else - template ::value || etl::is_pointer::value> - struct is_trivially_constructible; - template - struct is_trivially_constructible : public etl::true_type + struct is_trivially_constructible : public etl::bool_constant::value || etl::is_pointer::value> { }; - - template - struct is_trivially_constructible; #endif //********************************************* @@ -1567,16 +1561,10 @@ namespace etl { }; #else - template ::value || etl::is_pointer::value> - struct is_trivially_copy_constructible; - template - struct is_trivially_copy_constructible : public etl::true_type + struct is_trivially_copy_constructible : public etl::bool_constant::value || etl::is_pointer::value> { }; - - template - struct is_trivially_copy_constructible; #endif //********************************************* @@ -1587,16 +1575,10 @@ namespace etl { }; #else - template ::value || etl::is_pointer::value> - struct is_trivially_destructible; - template - struct is_trivially_destructible : public etl::true_type + struct is_trivially_destructible : public etl::bool_constant::value || etl::is_pointer::value> { }; - - template - struct is_trivially_destructible; #endif //********************************************* @@ -1607,16 +1589,10 @@ namespace etl { }; #else - template ::value || etl::is_pointer::value> - struct is_trivially_copy_assignable; - template - struct is_trivially_copy_assignable : public etl::true_type + struct is_trivially_copy_assignable : public etl::bool_constant::value || etl::is_pointer::value> { }; - - template - struct is_trivially_copy_assignable; #endif //********************************************* @@ -1627,16 +1603,10 @@ namespace etl { }; #else - template ::value || etl::is_pointer::value> - struct is_trivially_copyable; - template - struct is_trivially_copyable : public etl::true_type + struct is_trivially_copyable : public etl::bool_constant::value || etl::is_pointer::value> { }; - - template - struct is_trivially_copyable; #endif #elif defined(ETL_USE_TYPE_TRAITS_BUILTINS) && !defined(ETL_USER_DEFINED_TYPE_TRAITS) diff --git a/test/runtests.sh b/test/runtests.sh index d6bc72ba..30d63840 100755 --- a/test/runtests.sh +++ b/test/runtests.sh @@ -15,12 +15,18 @@ gcc --version | grep gcc | tee -a log.txt CC=gcc CXX=g++ cmake --cmake-clean-cache -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF .. make -j8 if [ $? -eq 0 ]; then - echo "Passed" + echo "<<<< Passed >>>>" +else + echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt + exit $? +fi +./etl_tests +if [ $? -eq 0 ]; then + echo "<<<< Passed >>>>" else echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt exit $? fi -./etl_tests | tee log.txt echo "" echo "-----------------------------------------------" | tee -a log.txt echo " GCC - STL - Force C++03" | tee -a log.txt @@ -29,12 +35,18 @@ gcc --version | grep gcc | tee -a log.txt CC=gcc CXX=g++ cmake --cmake-clean-cache -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=ON .. make -j8 if [ $? -eq 0 ]; then - echo "Passed" + echo "<<<< Passed >>>>" +else + echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt + exit $? +fi +./etl_tests +if [ $? -eq 0 ]; then + echo "<<<< Passed >>>>" else echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt exit $? fi -./etl_tests | tee log.txt echo "" echo "-----------------------------------------------" | tee -a log.txt echo " GCC - No STL" | tee -a log.txt @@ -43,12 +55,18 @@ gcc --version | grep gcc | tee -a log.txt CC=gcc CXX=g++ cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF .. make -j8 if [ $? -eq 0 ]; then - echo "Passed" + echo "<<<< Passed >>>>" +else + echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt + exit $? +fi +./etl_tests +if [ $? -eq 0 ]; then + echo "<<<< Passed >>>>" else echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt exit $? fi -./etl_tests | tee log.txt echo "" echo "-----------------------------------------------" | tee -a log.txt echo " GCC - No STL - Builtins" | tee -a log.txt @@ -57,12 +75,18 @@ gcc --version | grep gcc | tee -a log.txt CC=gcc CXX=g++ cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=ON -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF .. make -j8 if [ $? -eq 0 ]; then - echo "Passed" + echo "<<<< Passed >>>>" +else + echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt + exit $? +fi +./etl_tests +if [ $? -eq 0 ]; then + echo "<<<< Passed >>>>" else echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt exit $? fi -./etl_tests | tee log.txt #****************************************************************************** # CLANG @@ -75,12 +99,18 @@ clang --version | grep clang | tee -a log.txt CC=clang CXX=clang++ cmake --cmake-clean-cache -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF .. make -j8 if [ $? -eq 0 ]; then - echo "Passed" + echo "<<<< Passed >>>>" +else + echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt + exit $? +fi +./etl_tests +if [ $? -eq 0 ]; then + echo "<<<< Passed >>>>" else echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt exit $? fi -./etl_tests | tee log.txt echo "" echo "-----------------------------------------------" | tee -a log.txt echo " Clang - STL - Force C++03" | tee -a log.txt @@ -89,12 +119,18 @@ clang --version | grep clang | tee -a log.txt CC=clang CXX=clang++ cmake --cmake-clean-cache -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=ON .. make -j8 if [ $? -eq 0 ]; then - echo "Passed" + echo "<<<< Passed >>>>" +else + echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt + exit $? +fi +./etl_tests +if [ $? -eq 0 ]; then + echo "<<<< Passed >>>>" else echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt exit $? fi -./etl_tests | tee log.txt echo "" echo "-----------------------------------------------" | tee -a log.txt echo " Clang - No STL" | tee -a log.txt @@ -103,12 +139,18 @@ clang --version | grep clang | tee -a log.txt CC=clang CXX=clang++ cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF .. make -j8 if [ $? -eq 0 ]; then - echo "Passed" + echo "<<<< Passed >>>>" +else + echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt + exit $? +fi +./etl_tests +if [ $? -eq 0 ]; then + echo "<<<< Passed >>>>" else echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt exit $? fi -./etl_tests | tee log.txt echo "" echo "-----------------------------------------------" | tee -a log.txt echo " Clang - No STL - Builtins" | tee -a log.txt @@ -117,12 +159,18 @@ clang --version | grep clang | tee -a log.txt CC=clang CXX=clang++ cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=ON -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF .. make -j8 if [ $? -eq 0 ]; then - echo "Passed" + echo "<<<< Passed >>>>" +else + echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt + exit $? +fi +./etl_tests +if [ $? -eq 0 ]; then + echo "<<<< Passed >>>>" else echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt exit $? fi -./etl_tests | tee log.txt echo "" echo "-----------------------------------------------" | tee -a log.txt echo " Tests Completed" | tee -a log.txt diff --git a/test/test_delegate.cpp b/test/test_delegate.cpp index 9d2858ba..8d719916 100644 --- a/test/test_delegate.cpp +++ b/test/test_delegate.cpp @@ -29,6 +29,7 @@ SOFTWARE. #include "unit_test_framework.h" #include "etl/delegate.h" +#include "etl/vector.h" namespace { @@ -171,6 +172,12 @@ namespace } }; + //******************************************* + int times_2(int a) + { + return a * 2; + } + Test test_static; const Test const_test_static; } @@ -877,5 +884,15 @@ namespace CHECK(d1 != d2); } + + //************************************************************************* + TEST(test_issue_418) + { + etl::vector, 5> vector_of_delegates; + + vector_of_delegates.push_back(etl::delegate::create()); + + CHECK_EQUAL(42, vector_of_delegates.front()(21)); + } }; }