From 7df68346aa6f373bce1d52845451a32d20c17da7 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Fri, 10 Apr 2020 11:20:01 +0100 Subject: [PATCH] Make etl::array_view immutable by default --- .vs/.gitignore | 1 - .vs/ProjectSettings.json | 3 --- .vs/VSWorkspaceState.json | 10 ---------- include/etl/array_view.h | 20 ++++++++++++++++---- include/etl/version.h | 2 +- library.json | 2 +- library.properties | 2 +- support/Release notes.txt | 5 +++++ test/etl_profile.h | 1 + 9 files changed, 25 insertions(+), 21 deletions(-) delete mode 100644 .vs/.gitignore delete mode 100644 .vs/ProjectSettings.json delete mode 100644 .vs/VSWorkspaceState.json diff --git a/.vs/.gitignore b/.vs/.gitignore deleted file mode 100644 index 35226880..00000000 --- a/.vs/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/slnx.sqlite diff --git a/.vs/ProjectSettings.json b/.vs/ProjectSettings.json deleted file mode 100644 index 38c5f003..00000000 --- a/.vs/ProjectSettings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "CurrentProjectSetting": "x86-Debug" -} \ No newline at end of file diff --git a/.vs/VSWorkspaceState.json b/.vs/VSWorkspaceState.json deleted file mode 100644 index 9e5a6885..00000000 --- a/.vs/VSWorkspaceState.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "ExpandedNodes": [ - "", - "\\include", - "\\include\\etl", - "\\test" - ], - "SelectedNode": "\\test\\test_to_string.cpp", - "PreviewInSolutionExplorer": false -} \ No newline at end of file diff --git a/include/etl/array_view.h b/include/etl/array_view.h index 35e2fcad..0c1c3112 100644 --- a/include/etl/array_view.h +++ b/include/etl/array_view.h @@ -101,15 +101,23 @@ namespace etl typedef T value_type; typedef size_t size_type; - typedef T& reference; typedef const T& const_reference; - typedef T* pointer; typedef const T* const_pointer; - typedef T* iterator; typedef const T* const_iterator; - typedef ETL_OR_STD::reverse_iterator reverse_iterator; typedef ETL_OR_STD::reverse_iterator const_reverse_iterator; +#if defined(ETL_ARRAY_VIEW_IS_MUTABLE) + typedef T* pointer; + typedef T& reference; + typedef T* iterator; + typedef ETL_OR_STD::reverse_iterator reverse_iterator; +#else + typedef const_pointer pointer; + typedef const_reference reference; + typedef const_pointer iterator; + typedef const_reverse_iterator reverse_iterator; +#endif + //************************************************************************* /// Default constructor. //************************************************************************* @@ -369,6 +377,7 @@ namespace etl mend = etl::addressof(*begin_) + size_; } +#if defined(ETL_ARRAY_VIEW_IS_MUTABLE) //************************************************************************* /// Returns a reference to the indexed value. //************************************************************************* @@ -376,6 +385,7 @@ namespace etl { return mbegin[i]; } +#endif //************************************************************************* /// Returns a const reference to the indexed value. @@ -385,6 +395,7 @@ namespace etl return mbegin[i]; } +#if defined(ETL_ARRAY_VIEW_IS_MUTABLE) //************************************************************************* /// Returns a reference to the indexed value. //************************************************************************* @@ -394,6 +405,7 @@ namespace etl ETL_ASSERT(i < size(), ETL_ERROR(array_view_bounds)); return mbegin[i]; } +#endif //************************************************************************* /// Returns a const reference to the indexed value. diff --git a/include/etl/version.h b/include/etl/version.h index 5208254f..57d7971c 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -38,7 +38,7 @@ SOFTWARE. ///\ingroup utilities #define ETL_VERSION_MAJOR 17 -#define ETL_VERSION_MINOR 5 +#define ETL_VERSION_MINOR 6 #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_STRINGIFY(ETL_VERSION_MAJOR) L"." ETL_STRINGIFY(ETL_VERSION_MINOR) L"." ETL_STRINGIFY(ETL_VERSION_PATCH) diff --git a/library.json b/library.json index afd56863..8da86c29 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "Embedded Template Library", - "version": "17.5.0", + "version": "17.6.0", "authors": { "name": "John Wellbelove", "email": "john.wellbelove@etlcpp.com" diff --git a/library.properties b/library.properties index a4a1a566..610e602c 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Embedded Template Library -version=17.5.0 +version=17.6.0 author= John Wellbelove maintainer=John Wellbelove license=MIT diff --git a/support/Release notes.txt b/support/Release notes.txt index b3592907..96762d94 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -1,3 +1,8 @@ +=============================================================================== +17.6.0 +etl::array_view is non-mutable by default. +Mutable functionality is enabled by defining ETL_ARRAY_VIEW_IS_MUTABLE + =============================================================================== 17.5.0 Modified etl::message_packet to allow default construction, copy/move construction diff --git a/test/etl_profile.h b/test/etl_profile.h index 66a7cb46..f0b2f98e 100644 --- a/test/etl_profile.h +++ b/test/etl_profile.h @@ -39,6 +39,7 @@ SOFTWARE. #define ETL_IDEQUE_REPAIR_ENABLE #define ETL_IN_UNIT_TEST #define ETL_DEBUG_COUNT +#define ETL_ARRAY_VIEW_IS_MUTABLE #define ETL_MESSAGE_TIMER_USE_ATOMIC_LOCK #define ETL_CALLBACK_TIMER_USE_ATOMIC_LOCK