Followup on #6034 :
I believe we can (and should) make _Pairing_iterator_provider::_Iterator constructor private in the same way as that of value_compare.
The following code currently compiles, and I'm not convinced this is intended (note the + 1 added to values iterator).
using C = flat_map<int, char>;
typename C::key_container_type keys{42, 137, 137, 3337, 0};
typename C::mapped_container_type values{'a', 'g', 'f', 'f', 'r'};
typename C::iterator iter{keys.begin(), values.begin() + 1};
In #6035 I have added assertions that would prevent operations with iter in the example above. But making the constructor private seems even more robust as it prevents creating such iterators completely (unless we had a bug in flat_map).
Followup on #6034 :
I believe we can (and should) make
_Pairing_iterator_provider::_Iteratorconstructor private in the same way as that ofvalue_compare.The following code currently compiles, and I'm not convinced this is intended (note the + 1 added to
valuesiterator).In #6035 I have added assertions that would prevent operations with
iterin the example above. But making the constructor private seems even more robust as it prevents creating such iterators completely (unless we had a bug inflat_map).