<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 2571: &sect;[map.modifiers]/2 imposes nonsensical requirement on insert(InputIterator, InputIterator)</title>
<meta property="og:title" content="Issue 2571: &sect;[map.modifiers]/2 imposes nonsensical requirement on insert(InputIterator, InputIterator)">
<meta property="og:description" content="C++ library issue. Status: C++17">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue2571.html">
<meta property="og:type" content="website">
<meta property="og:image" content="http://cplusplus.github.io/LWG/images/cpp_logo.png">
<meta property="og:image:alt" content="C++ logo">
<style>
  p {text-align:justify}
  li {text-align:justify}
  pre code.backtick::before { content: "`" }
  pre code.backtick::after { content: "`" }
  blockquote.note
  {
    background-color:#E0E0E0;
    padding-left: 15px;
    padding-right: 15px;
    padding-top: 1px;
    padding-bottom: 1px;
  }
  ins {background-color:#A0FFA0}
  del {background-color:#FFA0A0}
  table.issues-index { border: 1px solid; border-collapse: collapse; }
  table.issues-index th { text-align: center; padding: 4px; border: 1px solid; }
  table.issues-index td { padding: 4px; border: 1px solid; }
  table.issues-index td:nth-child(1) { text-align: right; }
  table.issues-index td:nth-child(2) { text-align: left; }
  table.issues-index td:nth-child(3) { text-align: left; }
  table.issues-index td:nth-child(4) { text-align: left; }
  table.issues-index td:nth-child(5) { text-align: center; }
  table.issues-index td:nth-child(6) { text-align: center; }
  table.issues-index td:nth-child(7) { text-align: left; }
  table.issues-index td:nth-child(5) span.no-pr { color: red; }
  @media (prefers-color-scheme: dark) {
     html {
        color: #ddd;
        background-color: black;
     }
     ins {
        background-color: #225522
     }
     del {
        background-color: #662222
     }
     a {
        color: #6af
     }
     a:visited {
        color: #6af
     }
     blockquote.note
     {
        background-color: rgba(255, 255, 255, .10)
     }
  }
</style>
</head>
<body>
<hr>
<p><em>This page is a snapshot from the LWG issues list, see the <a href="lwg-active.html">Library Active Issues List</a> for more information and the meaning of <a href="lwg-active.html#C++17">C++17</a> status.</em></p>
<h3 id="2571"><a href="lwg-defects.html#2571">2571</a>. &sect;[map.modifiers]/2 imposes nonsensical requirement on <code>insert(InputIterator, InputIterator)</code></h3>
<p><b>Section:</b> 23.4.3.4 <a href="https://wg21.link/map.modifiers">[map.modifiers]</a> <b>Status:</b> <a href="lwg-active.html#C++17">C++17</a>
 <b>Submitter:</b> Tim Song <b>Opened:</b> 2015-12-12 <b>Last modified:</b> 2017-07-30</p>
<p><b>Priority: </b>0
</p>
<p><b>View all other</b> <a href="lwg-index.html#map.modifiers">issues</a> in [map.modifiers].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#C++17">C++17</a> status.</p>
<p><b>Discussion:</b></p>
<p>
The initial paragraphs of 23.4.3.4 <a href="https://wg21.link/map.modifiers">[map.modifiers]</a> currently read:
</p>
<blockquote>
<pre>
template &lt;class P&gt; pair&lt;iterator, bool&gt; insert(P&amp;&amp; x);
template &lt;class P&gt; iterator insert(const_iterator position, P&amp;&amp; x);
template &lt;class InputIterator&gt;
void insert(InputIterator first, InputIterator last);
</pre>
<blockquote>
<p>
-1- <i>Effects</i>: The first form is equivalent to <code>return emplace(std::forward&lt;P&gt;(x))</code>. The second form is
equivalent to <code>return emplace_hint(position, std::forward&lt;P&gt;(x))</code>.
<p/>
-2- <i>Remarks</i>: These signatures shall not participate in overload resolution unless <code>std::is_constructible&lt;value_type,
P&amp;&amp;&gt;::value</code> is <code>true</code>.
</p>
</blockquote>
</blockquote>
<p>
Clearly, p2's requirement makes no sense for <code>insert(InputIterator, InputIterator)</code> - it doesn't even have 
a template parameter called <code>P</code>.
<p/>
This paragraph used to have text saying "The signature taking <code>InputIterator</code> parameters does not require 
<code>CopyConstructible</code> of either <code>key_type</code> or <code>mapped_type</code> if the dereferenced <code>InputIterator</code> 
returns a non-<code>const</code> rvalue <code>pair&lt;key_type,mapped_type&gt;</code>. Otherwise <code>CopyConstructible</code> is 
required for both <code>key_type</code> and <code>mapped_type</code>", but that was removed by LWG <a href="lwg-defects.html#2005" title="unordered_map::insert(T&amp;&amp;) protection should apply to map too (Status: C++14)">2005</a><sup><a href="https://cplusplus.github.io/LWG/issue2005" title="Latest snapshot">(i)</a></sup>, whose PR 
was written as if that overload didn't exist in the text.
<p/>
It looks like the text addressing this overload is redundant to the requirements on <code>a.insert(i, j)</code> in Table 102 
that <code>value_type</code> be <code>EmplaceConstructible</code> from <code>*i</code>. If so, then the signature should just be 
deleted from this section.
</p>

<p><i>[2016-02, Issues Telecon]</i></p>

<p>
P0; move to Tentatively Ready.
</p>


<p id="res-2571"><b>Proposed resolution:</b></p>
<p>This wording is relative to N4567.</p>

<ol>
<li><p>Edit 23.4.3.4 <a href="https://wg21.link/map.modifiers">[map.modifiers]</a> as indicated:</p>

<blockquote>
<pre>
template &lt;class P&gt; pair&lt;iterator, bool&gt; insert(P&amp;&amp; x);
template &lt;class P&gt; iterator insert(const_iterator position, P&amp;&amp; x);
<del>template &lt;class InputIterator&gt;
void insert(InputIterator first, InputIterator last);</del>
</pre>
<blockquote>
<p>
-1- <i>Effects</i>: The first form is equivalent to <code>return emplace(std::forward&lt;P&gt;(x))</code>. The second form is
equivalent to <code>return emplace_hint(position, std::forward&lt;P&gt;(x))</code>.
<p/>
-2- <i>Remarks</i>: These signatures shall not participate in overload resolution unless <code>std::is_constructible&lt;value_type,
P&amp;&amp;&gt;::value</code> is <code>true</code>.
</p>
</blockquote>
</blockquote>

</li>
</ol>





</body>
</html>
