From 35c00ce9ed167113952b462e92b255c6a50f728f Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Wed, 31 Jul 2019 18:30:40 +0100 Subject: [PATCH] Added const parameters to etl::array_view --- include/etl/array_view.h | 32 ++++++++++++++++---------------- include/etl/version.h | 4 ++-- support/Release notes.txt | 4 ++++ 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/include/etl/array_view.h b/include/etl/array_view.h index b38d16af..52f99a4c 100644 --- a/include/etl/array_view.h +++ b/include/etl/array_view.h @@ -135,7 +135,7 @@ namespace etl /// Construct from iterators //************************************************************************* template - ETL_CONSTEXPR array_view(TIterator begin_, TIterator end_) + ETL_CONSTEXPR array_view(const TIterator begin_, const TIterator end_) : mbegin(etl::addressof(*begin_)), mend(etl::addressof(*begin_) + std::distance(begin_, end_)) { @@ -144,14 +144,14 @@ namespace etl //************************************************************************* /// Construct from C array //************************************************************************* - template - ETL_CONSTEXPR array_view(TIterator begin_, TSize size_) + ETL_CONSTEXPR array_view(const TIterator begin_, const TSize size_) : mbegin(etl::addressof(*begin_)), mend(etl::addressof(*begin_) + size_) { } - + //************************************************************************* /// Construct from C array //************************************************************************* @@ -353,7 +353,7 @@ namespace etl /// Assign from iterators //************************************************************************* template - void assign(TIterator begin_, TIterator end_) + void assign(const TIterator begin_, const TIterator end_) { mbegin = etl::addressof(*begin_); mend = etl::addressof(*begin_) + std::distance(begin_, end_); @@ -364,7 +364,7 @@ namespace etl //************************************************************************* template - void assign(TIterator begin_, TSize size_) + void assign(const TIterator begin_, const TSize size_) { mbegin = etl::addressof(*begin_); mend = etl::addressof(*begin_) + size_; @@ -373,7 +373,7 @@ namespace etl //************************************************************************* /// Returns a reference to the indexed value. //************************************************************************* - reference operator[](size_t i) + reference operator[](const size_t i) { return mbegin[i]; } @@ -381,7 +381,7 @@ namespace etl //************************************************************************* /// Returns a const reference to the indexed value. //************************************************************************* - const_reference operator[](size_t i) const + const_reference operator[](const size_t i) const { return mbegin[i]; } @@ -389,7 +389,7 @@ namespace etl //************************************************************************* /// Returns a reference to the indexed value. //************************************************************************* - reference at(size_t i) + reference at(const size_t i) { ETL_ASSERT((mbegin != nullptr && mend != nullptr), ETL_ERROR(array_view_uninitialised)); ETL_ASSERT(i < size(), ETL_ERROR(array_view_bounds)); @@ -399,7 +399,7 @@ namespace etl //************************************************************************* /// Returns a const reference to the indexed value. //************************************************************************* - const_reference at(size_t i) const + const_reference at(const size_t i) const { ETL_ASSERT((mbegin != nullptr && mend != nullptr), ETL_ERROR(array_view_uninitialised)); ETL_ASSERT(i < size(), ETL_ERROR(array_view_bounds)); @@ -415,18 +415,18 @@ namespace etl std::swap(mend, other.mend); } - //************************************************************************* + //************************************************************************* /// Shrinks the view by moving its start forward. - //************************************************************************* - void remove_prefix(size_type n) + //************************************************************************* + void remove_prefix(const size_type n) { mbegin += n; } - //************************************************************************* + //************************************************************************* /// Shrinks the view by moving its end backward. - //************************************************************************* - void remove_suffix(size_type n) + //************************************************************************* + void remove_suffix(const size_type n) { mend -= n; } diff --git a/include/etl/version.h b/include/etl/version.h index dbc39bca..a4508db2 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -38,8 +38,8 @@ SOFTWARE. ///\ingroup utilities #define ETL_VERSION_MAJOR 14 -#define ETL_VERSION_MINOR 28 -#define ETL_VERSION_PATCH 3 +#define ETL_VERSION_MINOR 29 +#define ETL_VERSION_PATCH 0 #define ETL_VERSION ETL_STRINGIFY(ETL_VERSION_MAJOR) ETL_STRINGIFY(ETL_VERSION_MINOR) ETL_STRINGIFY(ETL_VERSION_PATCH) #define ETL_VERSION_W ETL_WIDE_STRING(ETL_CONCAT(ETL_CONCAT(ETL_VERSION_MAJOR, ETL_VERSION_MINOR), ETL_VERSION_PATCH)) diff --git a/support/Release notes.txt b/support/Release notes.txt index d013c4cb..37e83bd0 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -1,3 +1,7 @@ +=============================================================================== +14.29.0 +Added const parameters and ETL_CONST_EXPR to etl::array_view + =============================================================================== 14.28.3 Removed redundant etl::const_array_view