From c220debdc5d9cc66270091f7c83b91be31ecabed Mon Sep 17 00:00:00 2001 From: Simon Hoinkis Date: Thu, 22 Apr 2021 16:08:57 +0200 Subject: [PATCH] iox-#261 Avoid code duplication in vector front() and back() Signed-off-by: Simon Hoinkis --- .../include/iceoryx_utils/internal/cxx/vector.inl | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/iceoryx_utils/include/iceoryx_utils/internal/cxx/vector.inl b/iceoryx_utils/include/iceoryx_utils/internal/cxx/vector.inl index 72bebd2a92..1252b11d45 100644 --- a/iceoryx_utils/include/iceoryx_utils/internal/cxx/vector.inl +++ b/iceoryx_utils/include/iceoryx_utils/internal/cxx/vector.inl @@ -296,9 +296,7 @@ inline T& vector::front() noexcept template inline const T& vector::front() const noexcept { - // No empty vector shall be accessed - cxx::Expects(!empty() && "Attempting to access the front of an empty vector"); - return at(0); + return const_cast*>(this)->front(); } template @@ -312,9 +310,7 @@ inline T& vector::back() noexcept template inline const T& vector::back() const noexcept { - // No empty vector shall be accessed - cxx::Expects(!empty() && "Attempting to access the back of an empty vector"); - return at(size() - 1); + return const_cast*>(this)->back(); } template