Skip to content

<flat_map>: Shouldn't the non-default _Pairing_iterator_provider::_Iterator ctor be private? #6036

Description

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementSomething can be improvedfixedSomething works now, yay!flat_meowC++23 container adaptors

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions