<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 484: Convertible to T</title>
<meta property="og:title" content="Issue 484: Convertible to T">
<meta property="og:description" content="C++ library issue. Status: Open">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue484.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#Open">Open</a> status.</em></p>
<h3 id="484"><a href="lwg-active.html#484">484</a>. Convertible to <code>T</code></h3>
<p><b>Section:</b> 24.3.5.3 <a href="https://wg21.link/input.iterators">[input.iterators]</a> <b>Status:</b> <a href="lwg-active.html#Open">Open</a>
 <b>Submitter:</b> Chris Jefferson <b>Opened:</b> 2004-09-16 <b>Last modified:</b> 2023-06-25</p>
<p><b>Priority: </b>3
</p>
<p><b>View other</b> <a href="lwg-index-open.html#input.iterators">active issues</a> in [input.iterators].</p>
<p><b>View all other</b> <a href="lwg-index.html#input.iterators">issues</a> in [input.iterators].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#Open">Open</a> status.</p>
<p><b>Discussion:</b></p>
<p>From comp.std.c++:</p>

<p>
I note that given an input iterator a for type <code>T</code>, 
then <code>*a</code> only has to be "convertable to <code>T</code>", 
not actually of type <code>T</code>.
</p>

<p>Firstly, I can't seem to find an exact definition of "convertable to <code>T</code>". 
While I assume it is the obvious definition (an implicit conversion), I 
can't find an exact definition. Is there one?</p>

<p>Slightly more worryingly, there doesn't seem to be any restriction on 
the this type, other than it is "convertable to <code>T</code>". Consider two input 
iterators <code>a</code> and <code>b</code>. I would personally assume that most people would 
expect <code>*a==*b</code> would perform <code>T(*a)==T(*b)</code>, however it doesn't seem that 
the standard requires that, and that whatever type <code>*a</code> is (call it <code>U</code>) 
could have == defined on it with totally different symantics and still 
be a valid inputer iterator.</p>

<p>Is this a correct reading? When using input iterators should I write 
<code>T(*a)</code> all over the place to be sure that the object I'm using is the 
class I expect?</p>

<p>This is especially a nuisance for operations that are defined to be
  "convertible to <code>bool</code>".  (This is probably allowed so that
  implementations could return say an <code>int</code> and avoid an unnecessary
  conversion. However all implementations I have seen simply return a
  <code>bool</code> anyway.  Typical implementations of STL algorithms just write
  things like <code>while(a!=b &amp;&amp; *a!=0)</code>.  But strictly
  speaking, there are lots of types that are convertible to <code>T</code> but
  that also overload the appropriate operators so this doesn't behave
  as expected.</p>

<p>If we want to make code like this legal (which most people seem to
  expect), then we'll need to tighten up what we mean by "convertible
  to <code>T</code>".</p>

<p><i>[Lillehammer: The first part is NAD, since "convertible" is
 well-defined in core. The second part is basically about pathological
 overloads. It's a minor problem but a real one. So leave open for
 now, hope we solve it as part of iterator redesign.]</i></p>


<p><i>[
2009-07-28 Reopened by Alisdair. No longer solved by concepts.
]</i></p>


<p><i>[
2009-10 Santa Cruz:
]</i></p>


<blockquote><p>
Mark as NAD Future. We agree there's an issue, but there is no
proposed solution at this time and this will be solved by concepts in
the future.
</p></blockquote>

<p><i>[2017-02 in Kona, LEWG recommends NAD]</i></p>

<p>Has been clarified by 14. By design. Ranges might make it go away. 
Current wording for input iterators is more constrained.</p>

<p><i>[2017-06-02 Issues Telecon]</i></p>

<p>Move to Open. This is very similar to <a href="lwg-active.html#2962" title="Iterators of Containers of move-only types do not model InputIterator (Status: Open)">2962</a><sup><a href="https://cplusplus.github.io/LWG/issue2962" title="Latest snapshot">(i)</a></sup>, possibly a duplicate.</p>
<p>Marshall to research</p>

<p><i>[2017-07 Toronto Thurs Issue Prioritization]</i></p>

<p>Priority 2; same as <a href="lwg-active.html#2962" title="Iterators of Containers of move-only types do not model InputIterator (Status: Open)">2962</a><sup><a href="https://cplusplus.github.io/LWG/issue2962" title="Latest snapshot">(i)</a></sup>.</p>

<p><strong>Previous resolution [SUPERSEDED]:</strong></p>
<blockquote class="note">

<p><b>Rationale:</b></p>
<p><i>[
San Francisco:
]</i></p>


<blockquote><p>
Solved by <a href="https://wg21.link/N2758" title=" Iterator Concepts for the C++0x Standard Library (Revision 5)">N2758</a>.
</p></blockquote>

</blockquote>

<p><i>[2023-06; Varna]</i></p>

<p>
During LWG discussion of this issue it was decided to reduce the priority to 3.
<p/>
Furthermore, the still presented "Solved by" comment has been recognized as being
no longer true, since the referred to pre-C++11 concept paper wording <a href="https://wg21.link/N2758" title=" Iterator Concepts for the C++0x Standard Library (Revision 5)">N2758</a> is no longer part
of the working paper.
<p/>
It also has been observed, that the "convertible to <code>bool</code>" part has since been resolved
by <a href="https://wg21.link/P1964" title=" Wording for boolean-testable">P1964</a> and the follow-up paper <a href="https://wg21.link/P2167" title=" Improved Proposed Wording for LWG 2114 (contextually convertible to bool)">P2167</a>.
<p/>
Also LWG <a href="lwg-active.html#3105" title="T1 is convertible to T2 (Status: New)">3105</a><sup><a href="https://cplusplus.github.io/LWG/issue3105" title="Latest snapshot">(i)</a></sup> has a lot of overlap with this issue.
</p>


<p id="res-484"><b>Proposed resolution:</b></p>





</body>
</html>
