<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 1105: Shouldn't Range be an auto concept</title>
<meta property="og:title" content="Issue 1105: Shouldn't Range be an auto concept">
<meta property="og:description" content="C++ library issue. Status: NAD Concepts">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue1105.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#NAD_Concepts">NAD Concepts</a> status.</em></p>
<h3 id="1105"><a href="lwg-closed.html#1105">1105</a>. Shouldn't <code>Range</code> be an <code>auto concept</code></h3>
<p><b>Section:</b> 99 [iterator.concepts.range] <b>Status:</b> <a href="lwg-active.html#NAD_Concepts">NAD Concepts</a>
 <b>Submitter:</b> David Abrahams <b>Opened:</b> 2009-04-23 <b>Last modified:</b> 2016-01-28</p>
<p><b>Priority: </b>Not Prioritized
</p>
<p><b>View all issues with</b> <a href="lwg-status.html#NAD Concepts">NAD Concepts</a> status.</p>
<p><b>Discussion:</b></p>

<p><i>[
2009-04-26 Herb adds:
]</i></p>


<blockquote>
<p>
Here's a common example: We have many ISV customers who have built lots of
in-house STL-like containers. Imagine that, for the past ten years, the user
has been happily using his <code>XYZCorpContainer&lt;T&gt;</code> that has <code>begin()</code> and <code>end()</code>
and an iterator typedef, and indeed satisfies nearly all of <code>Container</code>,
though maybe not quite all just like <code>valarray</code>. The user upgrades to a
range-enabled version of a library, and now <code>lib_algo( xyz.begin(), xyz.end());</code>
no longer works -- compiler error.
</p>
<p>
Even though <code>XYZCorpContainer</code> matches the pre-conceptized version of the
algorithm, and has been working for years, it appears the user has to write
at least this:
</p>
<blockquote><pre>
template&lt;class T&gt; concept_map Range&lt;XYZCorpContainer&lt;T&gt;&gt; {};

template&lt;class T&gt; concept_map Range&lt;const XYZCorpContainer&lt;T&gt;&gt; {};
</pre></blockquote>
<p>
Is that correct?
</p>
<p>
But he may actually have to write this as we do for initializer list:
</p>
<blockquote><pre>
template&lt;class T&gt;
concept_map Range&lt;XYZCorpContainer&lt;T&gt;&gt; {
   typedef T* iterator;
   iterator begin(XYZCorpContainer&lt;T&gt; c) { return c.begin(); }
   iterator end(XYZCorpContainer&lt;T&gt; c) { return c.end(); }
};

template&lt;class T&gt;
concept_map Range&lt;const XYZCorpContainer&lt;T&gt;&gt; {
   typedef T* iterator;
   iterator begin(XYZCorpContainer&lt;T&gt; c) { return c.begin(); }
   iterator end(XYZCorpContainer&lt;T&gt; c) { return c.end(); }
};
</pre></blockquote>

</blockquote>

<p><i>[
2009-04-28 Alisdair adds:
]</i></p>


<blockquote>
<p>
I recommend NAD, although remain concerned about header organisation.
</p>
<p>
A user container will satisfy the <code>MemberContainer</code> concept, which IS auto.
There is a concept_map for all <code>MemberContainers</code> to <code>Container</code>, and then a
further concept_map for all <code>Container</code> to <code>Range</code>, so the stated problem is not
actually true.  User defined containers will automatically match the <code>Range</code>
concept without explicitly declaring a concept_map.
</p>
<p>
The problem is that they should now provide an additional two headers,
<code>&lt;iterator_concepts&gt;</code> and <code>&lt;container_concepts&gt;</code>.
 The only difference from
making <code>Range</code> an auto concept would be this reduces to a single header,
<code>&lt;iterator_concepts&gt;</code>.
</p>
<p>
I am strongly in favour of any resolution that tackles the issue of
explicitly requiring concept headers to make these concept maps available.
</p>
</blockquote>

<p><i>[
Batavia (2009-05):
]</i></p>

<blockquote>
<p>
We observe there is a recent paper by Bjarne that overlaps this issue.
</p>
<p>
Alisdair continues to recommend NAD.
</p>
<p>
Move to Open, and recommend the issue be deferred until after the next
Committee Draft is issued.
</p>
</blockquote>


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





</body>
</html>
