diff --git a/src/deque.h b/src/deque.h index 533795df..bc41c24b 100644 --- a/src/deque.h +++ b/src/deque.h @@ -1797,9 +1797,17 @@ namespace etl //********************************************************************* void initialise() { - while (current_size > 0) + if (etl::is_trivially_destructible::value) { - destroy_element_back(); + current_size = 0; + construct_count.clear(); + } + else + { + while (current_size > 0) + { + destroy_element_back(); + } } _begin = iterator(0, *this, p_buffer); diff --git a/src/list.h b/src/list.h index b4c83130..c79f98a6 100644 --- a/src/list.h +++ b/src/list.h @@ -1442,13 +1442,21 @@ namespace etl { if (!empty()) { - node_t* p_first = terminal_node.next; - node_t* p_last = &terminal_node; - - while (p_first != p_last) + if (etl::is_trivially_destructible::value) { - destroy_data_node(static_cast(*p_first)); // Destroy the current node. - p_first = p_first->next; // Move to the next node. + p_node_pool->release_all(); + construct_count.clear(); + } + else + { + node_t* p_first = terminal_node.next; + node_t* p_last = &terminal_node; + + while (p_first != p_last) + { + destroy_data_node(static_cast(*p_first)); // Destroy the current node. + p_first = p_first->next; // Move to the next node. + } } } diff --git a/src/type_traits.h b/src/type_traits.h index 492296a8..127ee6ee 100644 --- a/src/type_traits.h +++ b/src/type_traits.h @@ -269,14 +269,14 @@ namespace etl /// is_pod /// For C++03, only fundamental and pointers types are recognised. ///\ingroup type_traits -#if (ETL_CPP11_SUPPORTED && !defined(ARDUINO))// && !defined(ETL_IN_UNIT_TEST) +#if (ETL_CPP11_SUPPORTED && !defined(ARDUINO)) && !defined(ETL_IN_UNIT_TEST) // For compilers that support C++11 template struct is_pod : std::is_pod {}; #else template struct is_pod : etl::integral_constant::value || etl::is_pointer::value> {}; #endif -#if (ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED) // && !defined(ETL_IN_UNIT_TEST) +#if (ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED) && !defined(ETL_IN_UNIT_TEST) /// is_trivially_constructible ///\ingroup type_traits template struct is_trivially_constructible : std::is_trivially_constructible {}; diff --git a/src/type_traits_generator.h b/src/type_traits_generator.h index bef84ee5..b4d488de 100644 --- a/src/type_traits_generator.h +++ b/src/type_traits_generator.h @@ -281,14 +281,14 @@ namespace etl /// is_pod /// For C++03, only fundamental and pointers types are recognised. ///\ingroup type_traits -#if (ETL_CPP11_SUPPORTED && !defined(ARDUINO))// && !defined(ETL_IN_UNIT_TEST) +#if (ETL_CPP11_SUPPORTED && !defined(ARDUINO)) && !defined(ETL_IN_UNIT_TEST) // For compilers that support C++11 template struct is_pod : std::is_pod {}; #else template struct is_pod : etl::integral_constant::value || etl::is_pointer::value> {}; #endif -#if (ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED) // && !defined(ETL_IN_UNIT_TEST) +#if (ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED) && !defined(ETL_IN_UNIT_TEST) /// is_trivially_constructible ///\ingroup type_traits template struct is_trivially_constructible : std::is_trivially_constructible {};