From 688ac131bb0326f00b4088c2202b83b610356728 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Thu, 11 May 2023 09:50:05 +0100 Subject: [PATCH] Removed [] operator --- include/etl/reference_flat_map.h | 29 +------------------- test/test_reference_flat_map.cpp | 46 -------------------------------- 2 files changed, 1 insertion(+), 74 deletions(-) diff --git a/include/etl/reference_flat_map.h b/include/etl/reference_flat_map.h index fe162a2e..e9d7b74e 100644 --- a/include/etl/reference_flat_map.h +++ b/include/etl/reference_flat_map.h @@ -42,6 +42,7 @@ SOFTWARE. #include "static_assert.h" #include "iterator.h" #include "type_traits.h" +#include "optional.h" #include "private/comparator_is_transparent.h" @@ -460,34 +461,6 @@ namespace etl return const_reverse_iterator(lookup.crend()); } - //********************************************************************* - /// Returns a reference to the value at index 'key' - ///\param i The index. - ///\return A reference to the value at index 'key' - //********************************************************************* - mapped_type& operator [](key_parameter_t key) - { - iterator i_element = lower_bound(key); - - ETL_ASSERT((i_element != end()) && keys_are_equal(i_element->first, key), ETL_ERROR(flat_map_out_of_bounds)); - - return i_element->second; - } - - //********************************************************************* - /// Returns a const reference to the value at index 'key' - ///\param i The index. - ///\return A const reference to the value at index 'key' - //********************************************************************* - const mapped_type& operator [](key_parameter_t key) const - { - iterator i_element = lower_bound(key); - - ETL_ASSERT((i_element != end()) && keys_are_equal(i_element->first, key), ETL_ERROR(flat_map_out_of_bounds)); - - return i_element->second; - } - //********************************************************************* /// Returns a reference to the value at index 'key' /// If asserts or exceptions are enabled, emits an etl::flat_map_out_of_bounds if the key is not in the range. diff --git a/test/test_reference_flat_map.cpp b/test/test_reference_flat_map.cpp index 91aaf07c..e7b98861 100644 --- a/test/test_reference_flat_map.cpp +++ b/test/test_reference_flat_map.cpp @@ -267,52 +267,6 @@ namespace CHECK(data.empty()); } - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_index) - { - Compare_DataDC compare_data(initial_data_dc.begin(), initial_data_dc.end()); - - DataDC data(initial_data_dc.begin(), initial_data_dc.end()); - - CHECK_EQUAL(compare_data[0], data[0]); - CHECK_EQUAL(compare_data[1], data[1]); - CHECK_EQUAL(compare_data[2], data[2]); - CHECK_EQUAL(compare_data[3], data[3]); - CHECK_EQUAL(compare_data[4], data[4]); - CHECK_EQUAL(compare_data[5], data[5]); - CHECK_EQUAL(compare_data[6], data[6]); - CHECK_EQUAL(compare_data[7], data[7]); - CHECK_EQUAL(compare_data[8], data[8]); - CHECK_EQUAL(compare_data[9], data[9]); - } - - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_index_value_changed) - { - Compare_DataDC compare_data; - DataDC data; - - DataDC::value_type item(0, M0); - - data.insert(item); - compare_data[0] = M0; - - bool isEqual = Check_Equal(data.begin(), - data.end(), - compare_data.begin()); - - CHECK(isEqual); - - data[0] = M2; - compare_data[0] = M2; - - isEqual = Check_Equal(data.begin(), - data.end(), - compare_data.begin()); - - CHECK(isEqual); - } - //************************************************************************* TEST_FIXTURE(SetupFixture, test_at) {