<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 2960: [fund.ts.v3] nonesuch is insufficiently useless</title>
<meta property="og:title" content="Issue 2960: [fund.ts.v3] nonesuch is insufficiently useless">
<meta property="og:description" content="C++ library issue. Status: C++23">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue2960.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++23">C++23</a> status.</em></p>
<h3 id="2960"><a href="lwg-defects.html#2960">2960</a>. [fund.ts.v3] <code>nonesuch</code> is insufficiently useless</h3>
<p><b>Section:</b> 6.3 <a href="https://cplusplus.github.io/fundamentals-ts/v3.html#meta">[fund.ts.v3::meta]</a> <b>Status:</b> <a href="lwg-active.html#C++23">C++23</a>
 <b>Submitter:</b> Tim Song <b>Opened:</b> 2017-05-08 <b>Last modified:</b> 2023-11-22</p>
<p><b>Priority: </b>2
</p>
<p><b>View all issues with</b> <a href="lwg-status.html#C++23">C++23</a> status.</p>
<p><b>Discussion:</b></p>
<p><b>Addresses: fund.ts.v3</b></p>
<p>
The definition of <code>std::experimental::nonesuch</code> (with a deleted default
constructor, destructor, copy constructor, and copy assignment
operator) means that it is an aggregate, which means that it can be
initialized from <code>{}</code> in contexts where the availability of the
destructor is not considered (e.g., overload resolution or a
new-expression).
<p/>
The deleted default constructor also has this effect standing alone,
because it doesn't affect the formation of implicit conversion
sequences (and hence overload resolution). The net result is
ambiguities in situations like:
</p>
<blockquote><pre>
struct such {};
void f(const such&amp;);
void f(const nonesuch&amp;);
f({});
</pre></blockquote>
<p>
For a real-life example of such ambiguity, see 
<a href="https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79141">GCC bug 79141</a>,
involving libstdc++'s internal <code>__nonesuch</code> type defined just like the
one in the fundamentals TS.
<p/>
I believe that <code>nonesuch</code> would be substantially more useful if the ICS
from <code>{}</code> is gone. <code>nonesuch</code> should have no default constructor (rather
than a deleted one), and it shouldn't be an aggregate.
</p>

<p><i>[2017-11-20 Priority set to 2 after discussion on the reflector.]</i></p>


<p><strong>Previous resolution [SUPERSEDED]:</strong></p>
<blockquote class="note">
<p>This wording is relative to <a href="https://wg21.link/n4617">N4617</a>.</p>

<ol>
<li>
<p>Edit 99 <a href="https://cplusplus.github.io/fundamentals-ts/v3.html#meta.type.synop">[fund.ts.v3::meta.type.synop]</a> as indicated, moving the definition of
<code>nonesuch</code> to 6.3.3 <a href="https://cplusplus.github.io/fundamentals-ts/v3.html#meta.detect">[fund.ts.v3::meta.detect]</a>:</p>

<blockquote>
<pre>
<i>//6.3.3 <a href="https://cplusplus.github.io/fundamentals-ts/v3.html#meta.detect">[fund.ts.v3::meta.detect]</a>, Detection idiom</i>
[&hellip;]

struct nonesuch<del>{
  nonesuch() = delete;
  ~nonesuch() = delete;
  nonesuch(nonesuch const&amp;) = delete;
  void operator=(nonesuch const&amp;) = delete;
}</del>;
[&hellip;]
</pre>
<blockquote>
<p>
</p>
</blockquote>
</blockquote>
</li>

<li>
<p>Insert at the beginning of 6.3.3 <a href="https://cplusplus.github.io/fundamentals-ts/v3.html#meta.detect">[fund.ts.v3::meta.detect]</a> the following paragraphs:</p>
 
<blockquote class="note">
<p>
[<i>Drafting note</i>: The seemingly redundant statement about default and initializer-list constructors
  is intended to negate the usual leeway for implementations to declare additional member function signatures 
  granted in 16.4.6.5 <a href="https://wg21.link/member.functions">[member.functions]</a>. &mdash; <i>end drafting note</i>]
</p>
</blockquote>
<blockquote>
<pre>
<ins>struct nonesuch {
  ~nonesuch() = delete;
  nonesuch(nonesuch const&amp;) = delete;
  void operator=(nonesuch const&amp;) = delete;
};</ins>
</pre>
<blockquote>
<p>
<ins>-?- <code>nonesuch</code> has no default constructor (C++14 &sect;[class.ctor]) or initializer-list 
  constructor (C++14 &sect;[dcl.init.list]), and is not an aggregate (C++14 &sect;[dcl.init.aggr]).</ins>
</p>
</blockquote>
</blockquote>
</li>
</ol>
</blockquote>


<p><i>[2018-08-23 Batavia Issues processing]</i></p>

<p>Change C++14 references to C++17, and all the LFTS2 references to LFTS3</p>
<p>Status to Tentatively Ready</p>
<p><i>[2018-11, Adopted in San Diego]</i></p>



<p id="res-2960"><b>Proposed resolution:</b></p>
<p>This wording is relative to <a href="https://wg21.link/n4617">N4617</a>.</p>

<ol>
<li>
<p>Edit 99 <a href="https://cplusplus.github.io/fundamentals-ts/v3.html#meta.type.synop">[fund.ts.v3::meta.type.synop]</a> as indicated, moving the definition of
<code>nonesuch</code> to 6.3.3 <a href="https://cplusplus.github.io/fundamentals-ts/v3.html#meta.detect">[fund.ts.v3::meta.detect]</a>:</p>

<blockquote>
<pre>
<i>//6.3.3 <a href="https://cplusplus.github.io/fundamentals-ts/v3.html#meta.detect">[fund.ts.v3::meta.detect]</a>, Detection idiom</i>
[&hellip;]

struct nonesuch<del>{
  nonesuch() = delete;
  ~nonesuch() = delete;
  nonesuch(nonesuch const&amp;) = delete;
  void operator=(nonesuch const&amp;) = delete;
}</del>;
[&hellip;]
</pre>
<blockquote>
<p>
</p>
</blockquote>
</blockquote>
</li>

<li>
<p>Insert at the beginning of 6.3.3 <a href="https://cplusplus.github.io/fundamentals-ts/v3.html#meta.detect">[fund.ts.v3::meta.detect]</a> the following paragraphs:</p>
 
<blockquote class="note">
<p>
[<i>Drafting note</i>: The seemingly redundant statement about default and initializer-list constructors
  is intended to negate the usual leeway for implementations to declare additional member function signatures 
  granted in 16.4.6.5 <a href="https://wg21.link/member.functions">[member.functions]</a>. &mdash; <i>end drafting note</i>]
</p>
</blockquote>
<blockquote>
<pre>
<ins>struct nonesuch {
  ~nonesuch() = delete;
  nonesuch(nonesuch const&amp;) = delete;
  void operator=(nonesuch const&amp;) = delete;
};</ins>
</pre>
<blockquote>
<p>
<ins>-?- <code>nonesuch</code> has no default constructor (C++17 &sect;[class.ctor]) or initializer-list 
  constructor (C++17 &sect;[dcl.init.list]), and is not an aggregate (C++17 &sect;[dcl.init.aggr]).</ins>
</p>
</blockquote>
</blockquote>
</li>
</ol>





</body>
</html>
