<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 2260: Missing requirement for Allocator::pointer</title>
<meta property="og:title" content="Issue 2260: Missing requirement for Allocator::pointer">
<meta property="og:description" content="C++ library issue. Status: C++17">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue2260.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="2260"><a href="lwg-defects.html#2260">2260</a>. Missing requirement for <code>Allocator::pointer</code></h3>
<p><b>Section:</b> 16.4.4.6 <a href="https://wg21.link/allocator.requirements">[allocator.requirements]</a> <b>Status:</b> <a href="lwg-active.html#C++17">C++17</a>
 <b>Submitter:</b> Jonathan Wakely <b>Opened:</b> 2013-05-14 <b>Last modified:</b> 2017-07-30</p>
<p><b>Priority: </b>3
</p>
<p><b>View other</b> <a href="lwg-index-open.html#allocator.requirements">active issues</a> in [allocator.requirements].</p>
<p><b>View all other</b> <a href="lwg-index.html#allocator.requirements">issues</a> in [allocator.requirements].</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>
For an allocator <code>A&lt;T&gt;</code> which defines <code>A&lt;T&gt;::pointer</code> to a class type,
i.e. not <code>T*</code>, I see no requirement that <code>A&lt;T&gt;::pointer</code> is convertible to
<code>A&lt;U&gt;::pointer</code>, even if <code>T*</code> is convertible to <code>U*</code>.  Such conversions are
needed in containers to convert from e.g. <code>ListNodeBase*</code> to <code>ListNode&lt;T&gt;*</code>.
</p>

<p>The obvious way to do such conversions appears to be
<code>pointer_traits::pointer_to()</code>, but that's ill-formed if the static
member function <code>A&lt;T&gt;::pointer::pointer_to()</code> doesn't exist and the
allocator requirements don't mention that function, so you need to
cast <code>A&lt;T&gt;::pointer</code> to <code>A&lt;T&gt;::void_pointer</code> then cast that to
<code>A&lt;U&gt;::pointer</code>.
</p>

<p>
Is converting via <code>void_pointer</code> really intended, or are we missing a requirement that 
<code>pointer_traits&lt;A&lt;T&gt;::pointer&gt;::pointer_to()</code> be well-formed?
</p>

<p>Proposed resolution:</p>

<p>Add to the Allocator requirements table the following requirement:</p>

<blockquote>
<p>
The expression <code>pointer_traits&lt;XX::pointer&gt;::pointer_to(r)</code> is well-defined.
</p>
</blockquote>

<p><i>[2013-09 Chicago]</i></p>

<p>
Pablo to come back with proposed wording
</p>

<p><i>[2015-07 Telecon]</i></p>

<p>
Marshall to ping Pablo for proposed wording and disable current wording.
</p>

<strong>Previous resolution [SUPERSEDED]:</strong>
<blockquote class = "note">
<ol>
<li><p>
Edit Table 28 as indicated:
</p>

<blockquote>
<table border="1">
<caption>Table 28 &mdash; Allocator requirements (continued)</caption>
<tr>
<th>Expression</th>
<th>Return type</th>
<th>Assertion&#47;note pre-&#47;post-condition</th>
<th>Default</th>
</tr>

<tr>
<td colspan="4" align="center">
<code>&hellip;</code>
</td>
</tr>

<tr>
<td>
<code>static_cast&lt;X::const_pointer&gt;(z)</code>
</td>
<td>
<code>X::const_pointer</code>
</td>
<td>
<code>static_cast&lt;X::const_pointer&gt;(z) == q</code>
</td>
<td>
&nbsp;
</td>
</tr>

<tr>
<td>
<ins><code>pointer_traits&lt;X::pointer&gt;::pointer_to(r)</code></ins>
</td>
<td>
<ins><code>X::pointer</code></ins>
</td>
<td>
&nbsp;
</td>
<td>
&nbsp;
</td>
</tr>

<tr>
<td colspan="4" align="center">
<code>&hellip;</code>
</td>
</tr>

</table>
</blockquote>


</li>
</ol>
</blockquote>


<p><i>[2016-11-12, Issaquah]</i></p>

<p>This is related to <a href="lwg-active.html#1521" title="Requirements on internal pointer representations in containers (Status: Open)">1521</a><sup><a href="https://cplusplus.github.io/LWG/issue1521" title="Latest snapshot">(i)</a></sup>.</p>
<p>Sat PM: Restore original P/R and move to tentatively ready.</p>


<p id="res-2260"><b>Proposed resolution:</b></p>
<ol>
<li><p>
Edit Table 28 as indicated:
</p>

<blockquote>
<table border="1">
<caption>Table 28 &mdash; Allocator requirements (continued)</caption>
<tr>
<th>Expression</th>
<th>Return type</th>
<th>Assertion&#47;note pre-&#47;post-condition</th>
<th>Default</th>
</tr>

<tr>
<td colspan="4" align="center">
<code>&hellip;</code>
</td>
</tr>

<tr>
<td>
<code>static_cast&lt;X::const_pointer&gt;(z)</code>
</td>
<td>
<code>X::const_pointer</code>
</td>
<td>
<code>static_cast&lt;X::const_pointer&gt;(z) == q</code>
</td>
<td>
&nbsp;
</td>
</tr>

<tr>
<td>
<ins><code>pointer_traits&lt;X::pointer&gt;::pointer_to(r)</code></ins>
</td>
<td>
<ins><code>X::pointer</code></ins>
</td>
<td>
&nbsp;
</td>
<td>
&nbsp;
</td>
</tr>

<tr>
<td colspan="4" align="center">
<code>&hellip;</code>
</td>
</tr>

</table>
</blockquote>


</li>
</ol>





</body>
</html>
