Title
flat_map::insert_range's Effects is not quite right
Status
new
Section
[flat.map.modifiers]
Submitter
Hewill Kang

Created on 2023-10-23.00:00:00 last changed 10 months ago

Messages

Date: 2024-02-22.16:51:49

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));
    }
    

    […]

Date: 2024-02-15.00:00:00

[ 2024-02-22; Reflector poll ]

Set priority to 3 after reflector poll in October 2023.

"This is P2767 section 6 which LWG looked at in Varna, and was turned into https://github.com/cplusplus/draft/pull/6274 as an editorial change."

Date: 2023-10-23.00:00:00

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.

History
Date User Action Args
2024-02-22 16:51:49adminsetmessages: + msg13965
2023-10-28 12:38:28adminsetmessages: + msg13771
2023-10-23 00:00:00admincreate