From e75f4bd248f5403ed229764618ab8e6edc186b5c Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sun, 13 Nov 2016 16:25:09 +0000 Subject: [PATCH] Changed 'Does nothing' comment to 'Undefined behavior' --- src/ibasic_string.h | 11 ++++++----- src/ipriority_queue.h | 13 +++++-------- src/iqueue.h | 2 +- src/istack.h | 2 +- src/ivector.h | 2 +- 5 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/ibasic_string.h b/src/ibasic_string.h index b788117a..34c6ba95 100644 --- a/src/ibasic_string.h +++ b/src/ibasic_string.h @@ -460,14 +460,15 @@ namespace etl //************************************************************************* /// Removes an element from the end of the string. - /// Does nothing if the string is empty. + /// Undefined behaviour if the string is empty. //************************************************************************* void pop_back() { - if (current_size > 0) - { - p_buffer[--current_size] = 0; - } +#if defined(ETL_CHECK_PUSH_POP) + ETL_ASSERT(!empty(), ETL_ERROR(string_empty)); +#endif + + p_buffer[--current_size] = 0; } //********************************************************************* diff --git a/src/ipriority_queue.h b/src/ipriority_queue.h index fd3cb832..74a11cfd 100644 --- a/src/ipriority_queue.h +++ b/src/ipriority_queue.h @@ -180,17 +180,14 @@ namespace etl //************************************************************************* /// Removes the oldest value from the back of the priority queue. - /// Does nothing if the priority queue is already empty. + /// Undefined behaviour if the priority queue is already empty. //************************************************************************* void pop() { - if (!empty()) - { - // Move largest element to end - std::pop_heap(container.begin(), container.end(), TCompare()); - // Actually remove largest element at end - container.pop_back(); - } + // Move largest element to end + std::pop_heap(container.begin(), container.end(), TCompare()); + // Actually remove largest element at end + container.pop_back(); } //************************************************************************* diff --git a/src/iqueue.h b/src/iqueue.h index 0f55963c..8d8751f2 100644 --- a/src/iqueue.h +++ b/src/iqueue.h @@ -162,7 +162,7 @@ namespace etl //************************************************************************* /// Removes the oldest value from the back of the queue. - /// Does nothing if the queue is already empty. + /// Undefined behaviour if the queue is already empty. //************************************************************************* void pop() { diff --git a/src/istack.h b/src/istack.h index 35e8107c..d742f452 100644 --- a/src/istack.h +++ b/src/istack.h @@ -135,7 +135,7 @@ namespace etl //************************************************************************* /// Removes the oldest item from the top of the stack. - /// Does nothing if the stack is already empty. + /// Undefined behaviour if the stack is already empty. //************************************************************************* void pop() { diff --git a/src/ivector.h b/src/ivector.h index 0dfe8491..a186a4a7 100644 --- a/src/ivector.h +++ b/src/ivector.h @@ -475,7 +475,7 @@ namespace etl //************************************************************************* /// Removes an element from the end of the vector. - /// Does nothing if the vector is empty. + /// Undefined behaviour if the vector is empty. //************************************************************************* void pop_back() {