Now that the iterators return a value (instead of a reference) of references, there is no reason to have the first()/second() API discrepancy when compared to std::map.
Replace PairView<const K, V> with std::pair<const K&, V&>.
One downside vs PairView is that iterating via const auto& no longer propagates const to the value, i.e.:
for (const auto& [key, value] : non_const_map)
{
// Can mutate value in here
}
because the const applies to the pointer, not the pointee.
Now that the iterators return a value (instead of a reference) of references, there is no reason to have the
first()
/second()
API discrepancy when compared tostd::map
.Replace
PairView<const K, V>
withstd::pair<const K&, V&>
.One downside vs
PairView
is that iterating viaconst auto&
no longer propagatesconst
to the value, i.e.:because the
const
applies to the pointer, not the pointee.Change from
PairView&
toPairView
occurred in an earlier PR: https://github.com/teslamotors/fixed-containers/pull/45Discussions and other attempts: https://github.com/teslamotors/fixed-containers/pull/38 https://github.com/teslamotors/fixed-containers/pull/39 https://github.com/teslamotors/fixed-containers/pull/40