<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 2310: Public exposition only member in std::array</title>
<meta property="og:title" content="Issue 2310: Public exposition only member in std::array">
<meta property="og:description" content="C++ library issue. Status: C++17">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue2310.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="2310"><a href="lwg-defects.html#2310">2310</a>. Public <em>exposition only</em> member in <code>std::array</code></h3>
<p><b>Section:</b> 23.3.3.1 <a href="https://wg21.link/array.overview">[array.overview]</a> <b>Status:</b> <a href="lwg-active.html#C++17">C++17</a>
 <b>Submitter:</b> Jonathan Wakely <b>Opened:</b> 2013-09-30 <b>Last modified:</b> 2017-07-30</p>
<p><b>Priority: </b>4
</p>
<p><b>View other</b> <a href="lwg-index-open.html#array.overview">active issues</a> in [array.overview].</p>
<p><b>View all other</b> <a href="lwg-index.html#array.overview">issues</a> in [array.overview].</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>
23.3.3.1 <a href="https://wg21.link/array.overview">[array.overview]</a> shows <code>std::array</code> with an "exposition only" data member, <code>elems</code>.
<p/>
The wording in 16.3.3.6 <a href="https://wg21.link/objects.within.classes">[objects.within.classes]</a> that defines how
"exposition only" is used says it applies to private members, but
<code>std::array::elems</code> (or its equivalent) must be public in order for
<code>std::array</code> to be an aggregate.
<p/>
If the intention is that <code>std::array::elems</code> places requirements on the
implementation to provide "equivalent external behavior" to a public
array member, then 16.3.3.6 <a href="https://wg21.link/objects.within.classes">[objects.within.classes]</a> needs to cover public
members too, or some other form should be used in 23.3.3.1 <a href="https://wg21.link/array.overview">[array.overview]</a>.
</p>

<p><i>[Urbana 2014-11-07: Move to Open]</i></p>

<p><i>[Kona 2015-10: Link to <a href="lwg-defects.html#2516" title="[fund.ts.v2] Public &quot;exposition only&quot; members in observer_ptr (Status: TS)">2516</a><sup><a href="https://cplusplus.github.io/LWG/issue2516" title="Latest snapshot">(i)</a></sup>]</i></p>

<p><i>[2015-11-14, Geoffrey Romer provides wording]</i></p>


<p><i>[2016-02-04, Tim Song improves the P/R]</i></p>

<p>
Instead of the build-in address-operator, <code>std::addressof</code> should be used.
</p>

<p><i>[2016-03 Jacksonville]</i></p>

Move to Ready.


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

<ol>
<li><p>Edit 23.3.3.1 <a href="https://wg21.link/array.overview">[array.overview]</a> as indicated</p>

<blockquote>
<p>
[&hellip;]
<p/>
-3- An array [&hellip;]
</p>
<blockquote><pre>
namespace std {
  template &lt;class T, size_t N&gt;
  struct array {
    [&hellip;]
    <del>T elems[N]; <i>// exposition only</i></del>
    [&hellip;]
  };
}
</pre></blockquote>
<p>
<del>-4- [<i>Note</i>: The member variable <code>elems</code> is shown for exposition only, to emphasize that array is a class aggregate.
The name <code>elems</code> is not part of array's interface. &mdash; <i>end note</i>]</del>
</p>
</blockquote>
</li>

<li><p>Edit  [array.data] as follows:</p>

<blockquote>
<pre>
constexpr T* data() noexcept;
constexpr const T* data() const noexcept;
</pre>
<blockquote>
<p>
-1- <i>Returns</i>: <del><code>elems</code></del><ins>A pointer such that <code>[data(), data() + size())</code> is a valid range, 
and <code>data() == addressof(front())</code></ins>.
</p>
</blockquote>
</blockquote>
</li>
</ol>





</body>
</html>
