4000. flat_map::insert_range's Effects is not quite right

Section: [flat.map.modifiers] Status: New Submitter: Hewill Kang Opened: 2023-10-23 Last modified: 2023-10-28 12:38:28 UTC

Priority: Not Prioritized

View all issues with New status.


flat_map::insert_range adds elements to the containers member via:

for (const auto& e : rg) {
  c.keys.insert(c.keys.end(), e.first);
  c.values.insert(c.values.end(), e.second);

which is incorrect because rg's value type may not be a pair (tuple, for instance), which means that .first and .second are not valid in such cases.

Proposed resolution:

This wording is relative to N4964.

  1. Modify [flat.map.modifiers] as indicated:

    template<container-compatible-range<value_type> R>
      void insert_range(R&& rg);

    -12- Effects: Adds elements to c as if by:

    for (value_typeconst auto& e : rg) {
      c.keys.insert(c.keys.end(), std::move(e.first));
      c.values.insert(c.values.end(), std::move(e.second));