<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 617: std::array is a sequence that doesn't satisfy the sequence requirements?</title>
<meta property="og:title" content="Issue 617: std::array is a sequence that doesn't satisfy the sequence requirements?">
<meta property="og:description" content="C++ library issue. Status: Open">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue617.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="617"><a href="lwg-active.html#617">617</a>. <code>std::array</code> is a sequence that doesn't satisfy the sequence requirements?</h3>
<p><b>Section:</b> 23.3.3 <a href="https://wg21.link/array">[array]</a> <b>Status:</b> <a href="lwg-active.html#Open">Open</a>
 <b>Submitter:</b> Bo Persson <b>Opened:</b> 2006-12-30 <b>Last modified:</b> 2022-11-12</p>
<p><b>Priority: </b>3
</p>
<p><b>View all other</b> <a href="lwg-index.html#array">issues</a> in [array].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#Open">Open</a> status.</p>
<p><b>Discussion:</b></p>
<p>
The <code>&lt;array&gt;</code> header is given under 23.3 <a href="https://wg21.link/sequences">[sequences]</a>.
23.3.3 <a href="https://wg21.link/array">[array]</a>/paragraph 3 says:
</p>
<blockquote><p>
"Unless otherwise specified, all array operations are as described in
23.2 <a href="https://wg21.link/container.requirements">[container.requirements]</a>".
</p></blockquote>
<p>
However, <code>array</code> isn't mentioned at all in section 23.2 <a href="https://wg21.link/container.requirements">[container.requirements]</a>.
In particular, Table 82 "Sequence requirements" lists several operations (insert, erase, clear) 
that <code>std::array</code> does not have in 23.3.3 <a href="https://wg21.link/array">[array]</a>.
</p>
<p>
Also, Table 83 "Optional sequence operations" lists several operations that 
<code>std::array</code> does have, but array isn't mentioned.
</p>

<p><i>[
2009-07 Frankfurt
]</i></p>


<blockquote>
<p>
The real issue seems to be different than what is described here.
Non-normative text says that <code>std::array</code> is a sequence container, but
there is disagreement about what that really means. There are two
possible interpretations:
</p>
<ol>
<li>
a sequence container is one that satisfies all sequence container requirements
</li>
<li>
a sequence container is one that satisfies some of the sequence
container requirements. Any operation that the container supports is
specified by one or more sequence container requirements, unless that
operation is specifically singled out and defined alongside the
description of the container itself.
</li>
</ol>
<p>
Move to Tentatively NAD.
</p>
</blockquote>

<p><i>[
2009-07-15 Lo&iuml;c Joly adds:
]</i></p>


<blockquote>
<p>
The section 23.2.4 <a href="https://wg21.link/sequence.reqmts">[sequence.reqmts]</a>/1 states that array is a sequence. 23.2.4 <a href="https://wg21.link/sequence.reqmts">[sequence.reqmts]</a>/3
introduces table 83, named Sequence container requirements. This seems
to me to be defining the requirements for all sequences. However, array
does not follow all of this requirements (this can be read in the array
specific section, for the standard is currently inconsistent).
</p>

<p>
Proposed resolution 1 (minimal change): 
</p>
<blockquote>
<p>
Say that array is a container, that in addition follows only some of the
sequence requirements, as described in the array section:
</p>

<blockquote><p>
The library provides <del>five</del> <ins>three</ins> basic kinds of sequence containers: <del><code>array</code></del>,
<code>vector</code>, 
<del><code>forward_list</code></del>, <code>list</code>, and <code>deque</code>. <ins>In addition, <code>array</code>
and <code>forward_list</code> follows some of the requirements 
of sequences, as described in their respective sections.</ins>
</p></blockquote>

</blockquote>

<p>
Proposed resolution 2 (most descriptive description, no full wording provided): 
</p>
<blockquote><p>
Introduce the notion of a Fixed Size Sequence, with it requirement table
that would be a subset of the current Sequence container. array would be
the only Fixed Size Sequence (but dynarray is in the queue for TR2).
Sequence requirements would now be requirements in addition to Fixed
Size Sequence requirements (it is currently in addition to container).
</p></blockquote>
</blockquote>

<p><i>[
2009-07 Frankfurt:
]</i></p>


<blockquote><p>
Move to NAD Editorial
</p></blockquote>

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


<blockquote><p>
This will require a lot of reorganization. Editor doesn't think this is really
an issue, since the description of array can be considered as overriding
what's specified about sequences. Move to NAD.
</p></blockquote>

<p><i>[2022-10-27; Hubert Tong comments and requests to reopen]</i></p>

<p>
This issue appears to be unresolved (should not be NAD).
<p/>
As noted in 23.3.3.1 <a href="https://wg21.link/array.overview">[array.overview]</a> paragraph 3, <code>array</code> 
does not meet 23.2.2.2 <a href="https://wg21.link/container.reqmts">[container.reqmts]</a> paragraph 10. This means that 
<code>array</code> does not meet the container requirements, never mind the requirements 
for sequence containers or contiguous containers.
<p/>
However, there is wording that claims the opposite.
<p/>
23.2.4 <a href="https://wg21.link/sequence.reqmts">[sequence.reqmts]</a> paragraph 1:
</p>
<blockquote><p>
In addition, <code>array</code> is provided as a sequence container which provides limited sequence operations 
because it has a fixed number of elements.
</p></blockquote>
<p>
(Perhaps the above should be worded with "except".)
<p/>
23.3.1 <a href="https://wg21.link/sequences.general">[sequences.general]</a> paragraph 1:
</p>
<blockquote><p>
The headers <code>&lt;array&gt;</code> [&hellip;] define class templates that meet the requirements for sequence containers.
</p></blockquote>
<p>
23.3.3.1 <a href="https://wg21.link/array.overview">[array.overview]</a> paragraph 1:
</p>
<blockquote><p>
[&hellip;] An <code>array</code> is a contiguous container (23.2.2 <a href="https://wg21.link/container.requirements.general">[container.requirements.general]</a>).
</p></blockquote>
<p>
In <a href="https://github.com/cplusplus/draft/issues/5916#issuecomment-1291327657">this comment</a>, 
Casey suggests that the requirements be changed so that <code>array</code> does meet the requirements.
</p>

<p><i>[Kona 2022-11-12; Set Priority to 3]</i></p>



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





</body>
</html>
