<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 3019: Presentation of "program defined classes derived from error_category" [syserr.errcat.derived] unclear and contains mistakes</title>
<meta property="og:title" content="Issue 3019: Presentation of &quot;program defined classes derived from error_category&quot; [syserr.errcat.derived] unclear and contains mistakes">
<meta property="og:description" content="C++ library issue. Status: New">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue3019.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#New">New</a> status.</em></p>
<h3 id="3019"><a href="lwg-active.html#3019">3019</a>. Presentation of "program defined classes derived from <code>error_category</code>" [syserr.errcat.derived] unclear and contains mistakes</h3>
<p><b>Section:</b> 19.5.3.4 <a href="https://wg21.link/syserr.errcat.derived">[syserr.errcat.derived]</a> <b>Status:</b> <a href="lwg-active.html#New">New</a>
 <b>Submitter:</b> Thomas K&ouml;ppe <b>Opened:</b> 2017-09-20 <b>Last modified:</b> 2017-11-09</p>
<p><b>Priority: </b>3
</p>
<p><b>View all issues with</b> <a href="lwg-status.html#New">New</a> status.</p>
<p><b>Discussion:</b></p>
<p>
The presentation of section [syserr.errcat.derived] is currently somewhat problematic:
</p>
<ul>
<li><p>
It is not clear why this section exists and what it is specifying. Presumably, it is the subject of the phrase 
"in this subclause" of the sibling section [syserr.errcat.overview], but that's confusing (because this would require the 
interpretation of "this subclause" as the containing superclause). It would be an improvement to say "shall behave 
as specified in [syserr.errcat.derived]" in the introduction.
</p></li>
<li><p>
The current wording of [syserr.errcat.derived] requires that derived classes keep the <code>name</code> member function pure-virtual, 
making it impossible to have non-abstract derived classes. This appears to be an editorial error. Surely <code>name</code> should 
just not be required to be pure-virtual.
</p></li>
<li><p>
There seems to be no requirement concerning the <code>message</code> virtual member function.
</p></li>
<li><p>
We should use <code>override</code> rather than <code>virtual</code>.
</p></li>
<li><p>
I would welcome a short, introductory paragraph in [syserr.errcat.derived] that states (non-redundantly) that the following 
are requirements on users' derived classes.
</p></li>
</ul>
<p>
Partial wording proposal:
</p>
<ol>
<li><p>In 19.5.3.1 <a href="https://wg21.link/syserr.errcat.overview">[syserr.errcat.overview]</a> p1, change:</p>
<blockquote>
<p>
-1- The class <code>error_category</code> serves as a base class for types used to identify the source and encoding of a
particular category of error code. Classes may be derived from <code>error_category</code> to support categories of
errors in addition to those defined in this International Standard. Such classes shall behave as specified in
<del>this subclause</del><ins>19.5.3.4 <a href="https://wg21.link/syserr.errcat.derived">[syserr.errcat.derived]</a></ins>. [<i>Note:</i> <code>error_category</code> objects 
are passed by reference, and two such objects are equal if they have the same address. This means that applications 
using custom <code>error_category</code> types should create a single object of each such type. &mdash; <i>end note</i>]
</p>
</blockquote>
</li>

<li><p>In 19.5.3.4 <a href="https://wg21.link/syserr.errcat.derived">[syserr.errcat.derived]</a>, change:</p>
<blockquote>
<pre>
<del>virtual</del> const char* name() const noexcept <ins>override</ins> <del> = 0</del>;
</pre>
<blockquote>
<p>
-1- <i>Returns:</i> A string naming the error category.
</p>
</blockquote>
<pre>
<del>virtual</del> error_condition default_error_condition(int ev) const noexcept <ins>override</ins>;
</pre>
<blockquote>
<p>
-2- <i>Returns:</i> An object of type <code>error_condition</code> that corresponds to <code>ev</code>.
</p>
</blockquote>
<pre>
<del>virtual</del> bool equivalent(int code, const error_condition&amp; condition) const noexcept <ins>override</ins>;
</pre>
<blockquote>
<p>
-3- <i>Returns:</i> <code>true</code> if, for the category of error represented by <code>*this</code>, <code>code</code> is considered 
equivalent to <code>condition</code>; otherwise, <code>false</code>.
</p>
</blockquote>
<pre>
<del>virtual</del> bool equivalent(const error_code&amp; code, int condition) const noexcept <ins>override</ins>;
</pre>
<blockquote>
<p>
-4- <i>Returns:</i> <code>true</code> if, for the category of error represented by <code>*this</code>, <code>code</code> is considered 
equivalent to condition; otherwise, <code>false</code>.
</p>
</blockquote>
</blockquote>
</li>
</ol>

<p><i>[2017-11 Albuquerque Wednesday night issues processing]</i></p>

<p>Priority set to 3.</p>
<p>Jonathan to talk to Chris K and Walter about writing a paper describing the use of <code>error_code</code>, <code>error_condition</code> and defining your own.</p>


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





</body>
</html>
