This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++17 status.

### 2571. §[map.modifiers]/2 imposes nonsensical requirement on `insert(InputIterator, InputIterator)`

Section: 22.4.4.4 [map.modifiers] Status: C++17 Submitter: Tim Song Opened: 2015-12-12 Last modified: 2017-07-30

Priority: 0

View all other issues in [map.modifiers].

View all issues with C++17 status.

Discussion:

The initial paragraphs of 22.4.4.4 [map.modifiers] currently read:

>     template <class P> pair<iterator, bool> insert(P&& x);
>     template <class P> iterator insert(const_iterator position, P&& x);
>     template <class InputIterator>
>     void insert(InputIterator first, InputIterator last);

> > -1- Effects: The first form is equivalent to `return emplace(std::forward<P>(x))`. The second form is equivalent to `return emplace_hint(position, std::forward<P>(x))`.

> > -2- Remarks: These signatures shall not participate in overload resolution unless `std::is_constructible<value_type, P&&>::value` is `true`.

Clearly, p2's requirement makes no sense for `insert(InputIterator, InputIterator)` - it doesn't even have a template parameter called `P`.

This paragraph used to have text saying "The signature taking `InputIterator` parameters does not require `CopyConstructible` of either `key_type` or `mapped_type` if the dereferenced `InputIterator` returns a non-`const` rvalue `pair<key_type,mapped_type>`. Otherwise `CopyConstructible` is required for both `key_type` and `mapped_type`", but that was removed by LWG 2005, whose PR was written as if that overload didn't exist in the text.

It looks like the text addressing this overload is redundant to the requirements on `a.insert(i, j)` in Table 102 that `value_type` be `EmplaceConstructible` from `*i`. If so, then the signature should just be deleted from this section.

[2016-02, Issues Telecon]

P0; move to Tentatively Ready.

Proposed resolution:

This wording is relative to N4567.

1. Edit 22.4.4.4 [map.modifiers] as indicated:

   >     template <class P> pair<iterator, bool> insert(P&& x);
   >     template <class P> iterator insert(const_iterator position, P&& x);
   >     template <class InputIterator>
   >     void insert(InputIterator first, InputIterator last);

   > > -1- Effects: The first form is equivalent to `return emplace(std::forward<P>(x))`. The second form is equivalent to `return emplace_hint(position, std::forward<P>(x))`.

   > > -2- Remarks: These signatures shall not participate in overload resolution unless `std::is_constructible<value_type, P&&>::value` is `true`.