Removed [] operator

This commit is contained in:
John Wellbelove 2023-05-11 09:50:05 +01:00
parent eaebff65b9
commit 688ac131bb
2 changed files with 1 additions and 74 deletions

View File

@ -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.

View File

@ -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)
{