diff --git a/src/iforward_list.h b/src/iforward_list.h index b663ad8e..0f418209 100644 --- a/src/iforward_list.h +++ b/src/iforward_list.h @@ -256,7 +256,7 @@ namespace etl const Node* p_node; }; - typedef typename std::iterator_traits::difference_type difference_type; + typedef typename std::iterator_traits::difference_type difference_type; //************************************************************************* /// Gets the beginning of the forward_list. @@ -348,7 +348,7 @@ namespace etl //************************************************************************* /// Assigns a range of values to the forward_list. - /// If asserts or exceptions are enabled throws etl::forward_list_full if the forward_list does not have enough free space. + /// If asserts or exceptions are enabled throws etl::forward_list_full if the forward_list does not have enough free space. /// If ETL_THROW_EXCEPTIONS & _DEBUG are defined throws forward_list_iterator if the iterators are reversed. //************************************************************************* template @@ -707,7 +707,7 @@ namespace etl if (is_trivial_list()) { - return; + return; } while (true) @@ -746,32 +746,32 @@ namespace etl // Decide whether the next node of merge comes from left or right. if (left_size == 0) { - // Left is empty. The node must come from right. - p_node = p_right; + // Left is empty. The node must come from right. + p_node = p_right; ++p_right; --right_size; - } + } else if (right_size == 0 || p_right == end()) { - // Right is empty. The node must come from left. - p_node = p_left; + // Right is empty. The node must come from left. + p_node = p_left; ++p_left; --left_size; - } + } else if (compare(*p_left, *p_right)) { - // First node of left is lower or same. The node must come from left. - p_node = p_left; + // First node of left is lower or same. The node must come from left. + p_node = p_left; ++p_left; --left_size; - } + } else { - // First node of right is lower. The node must come from right. - p_node = p_right; + // First node of right is lower. The node must come from right. + p_node = p_right; ++p_right; --right_size; - } + } // Add the next node to the merged head. if (p_head == before_begin())