<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Concepts for Diagnostics</title>
</head>

<body>

<p>Document number: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; N2620=08-0130<br>
Date:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y-%m-%d" startspan -->2008-05-19<!--webbot bot="Timestamp" endspan i-checksum="12357" --><br>
Project:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
Programming Language C++, Library Working Group<br>
Reply-to:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
Beman Dawes &lt;bdawes at acm.org&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Daniel 
Krgler <span class="HcCDpe"><span class="lDACoc">&lt;daniel.kruegler at 
googlemail.com&gt;<br>
</span></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
Douglas Gregor &lt;dgregor at cs.indiana.edu&gt;</p>
<h1>Concepts for the C++0x Standard Library: Diagnostics library</h1>
<h2>Introduction</h2>
<p>This document proposes changes to Chapter 19 of the C++ Standard Library in 
order to make full use of concepts <a href="#1">[1]</a>. A prototype of the proposed resolution wording has been implemented and 
tested using <a href="http://www.generic-programming.org/software/ConceptGCC/">
ConceptGCC</a>. Because the only component affected is new to C++0x, there is no 
issue of backward compatibility.</p>
<p>This document is formatted in the same manner as the working draft of the C++ 
standard. Future versions of this document will track the working draft and the 
concepts proposal as they evolve. Proposed changes to the working paper provide 
enough current text to supply context, but only <strike><font color="#FF0000">
red current text with strikethrough</font></strike> is to be deleted, and only
<u><font color="#009A9A">blue-green text with underscore</font></u> is to be 
added, unless editorial comments state otherwise. <i>Editorial comments are in 
italics.</i></p>
<h2>Proposed wording</h2>
<p><i>The proposed wording assumes LWG 805, </i>posix_error::posix_errno 
concerns<i>, has been accepted and its proposed wording applied to 
the WP. If resolution of that issue changes the name </i><code>posix_errno</code><i> 
to some name other than </i><code>errc</code><i>, the wording of this proposal 
should be applied with the new name (in two places).</i></p>
<p><i>If LWG 805 has not been applied, all uses of&nbsp; </i><code>err<i>c </i>
</code><i>should be changed to<code> </code></i><code> posix_error::posix_errno</code>&nbsp;<i> and the 
namespace around the </i><code>make_error_code</code><i>/</i><code>make_condition_code</code><i> set of functions should 
be removed.</i></p>
<p><i>The proposed wording assumes LWG 832, </i>Applying constexpr to System 
error support<i>, has been accepted and its proposed wording applied to the WP. 
If it has not been accepted, strike <code>constexpr</code> from this proposal 
(in two places).</i></p>
<p><i>Change 19.4 System error support [syserr], Header &lt;system_error&gt; synopsis:</i></p>
<blockquote>
  <pre><strike><font color="#FF0000">template &lt;class T&gt;
struct is_error_code_enum : public false_type {};
</font></strike>
<strike><font color="#FF0000">template &lt;class T&gt;
struct is_error_condition_enum : public false_type {};
</font></strike>
<font color="#0099CC"><u>concept ErrorCodeEnum&lt;typename T&gt; <i>see below</i></u></font>

<font color="#0099CC"><u>concept ErrorConditionEnum&lt;typename T&gt; <i>see below</i>

</u></font><i>...</i><font color="#0099CC"><u>

</u></font><strike><font color="#FF0000">template &lt;&gt; struct is_error_condition_enum&lt;errc&gt;
  : public true_type {}

</font></strike><font color="#0099CC"><u>concept_map ErrorConditionEnum&lt;errc&gt; {};</u></font>
</pre>
</blockquote>
<p><i>At a location to be determined by the Project Editor, insert:</i></p>
<blockquote>
<p><code>concept ErrorCodeEnum&lt;typename T&gt; : EnumerationType&lt;T&gt; {<br>
&nbsp; constexpr error_code make_error_code(T val);<br>
&nbsp; }</code></p>
  <blockquote>
<p>Describes types to be used as an argument to function <code>make_error_code</code>.</p>
<p><i>Requires: </i>Function <code>make_error_code</code> shall return <code>
error_code(static_cast&lt;int&gt;(val), cat)</code>, where <code>cat</code> is an
<code>error_category</code> that describes type <code>T</code>.</p>
  </blockquote>
<p><code>concept ErrorConditionEnum&lt;typename T&gt; : EnumerationType&lt;T&gt; {<br>
&nbsp; constexpr error_condition make_error_condition(T val);<br>
&nbsp; }</code></p>
  <blockquote>
<p>Describes types to be used as an argument to function <code>
make_error_condition</code>.</p>
<p><i>Requires: </i>Function <code>make_error_condition</code> shall return
<code>error_condition(static_cast&lt;int&gt;(val), cat)</code>, where <code>cat</code> 
is an <code>error_category</code> that describes type <code>T</code>.</p>
  </blockquote>
</blockquote>
<p><i>Change 19.4.2.1 Class error_code overview [syserr.errcode.overview], class 
error_code synopsis:</i></p>
<blockquote>
  <pre>template &lt;<strike><font color="#FF0000">class</font></strike> ErrorCodeEnum <font color="#0099CC"><u>E</u></font>&gt;
&nbsp;&nbsp; error_code(<strike><font color="#FF0000">ErrorCodeEnum</font></strike> <font color="#0099CC"><u>E</u></font> e<font color="#FF0000"><strike>,
</strike>&nbsp;&nbsp;&nbsp;&nbsp; <strike>typename enable_if&lt;is_error_code_enum&lt;ErrorCodeEnum&gt;::value&gt;::type * = 0</strike></font>);

...

template &lt;<strike><font color="#FF0000">class</font></strike> ErrorCodeEnum <font color="#0099CC"><u>E</u></font>&gt;
  <strike><font color="#FF0000">typename enable_if&lt;is_error_code_enum&lt;ErrorCodeEnum&gt;::value&gt;::type&amp;</font></strike> <font color="#0099CC"><u>error_code&amp;</u></font>
    operator=(<strike><font color="#FF0000">ErrorCodeEnum</font></strike> <font color="#0099CC"><u>E</u></font> e);</pre>
</blockquote>
<p><i>Change 19.4.2.2 Class error_code constructors [syserr.errcode.constructors]:</i></p>
<blockquote>
  <pre>template &lt;<strike><font color="#FF0000">class</font></strike> ErrorCodeEnum <font color="#0099CC"><u>E</u></font>&gt;
&nbsp;&nbsp; error_code(<strike><font color="#FF0000">ErrorCodeEnum</font></strike> <font color="#0099CC"><u>E</u></font> e<font color="#FF0000"><strike>,
</strike>&nbsp;&nbsp;&nbsp;&nbsp; <strike>typename enable_if&lt;is_error_code_enum&lt;ErrorCodeEnum&gt;::value&gt;::type * = 0</strike></font>);</pre>
</blockquote>
<p><i>Change 19.4.2.3 Class error_code modifiers [syserr.errcode.modifiers]:</i></p>
<blockquote>
  <pre>template &lt;<strike><font color="#FF0000">class</font></strike> ErrorCodeEnum <font color="#0099CC"><u>E</u></font>&gt;
  <strike><font color="#FF0000">typename enable_if&lt;is_error_code_enum&lt;ErrorCodeEnum&gt;::value&gt;::type&amp;</font></strike> <font color="#0099CC"><u>error_code&amp;</u></font>
    operator=(<strike><font color="#FF0000">ErrorCodeEnum</font></strike> <font color="#0099CC"><u>E</u></font> e);</pre>
</blockquote>
<p><i>Change 19.4.3.1 Class error_condition overview [syserr.errcondition.overview], 
class error_condition synopsis:</i></p>
<blockquote>
  <pre>template &lt;<strike><font color="#FF0000">class</font></strike> ErrorConditionEnum <font color="#0099CC"><u>E</u></font>&gt;
&nbsp;&nbsp; error_condition(<strike><font color="#FF0000">Error</font></strike><font color="#FF0000"><strike>Condition</strike></font><strike><font color="#FF0000">Enum</font></strike> <font color="#0099CC"><u>E</u></font> e<font color="#FF0000"><strike>,
</strike>&nbsp;&nbsp;&nbsp;&nbsp; <strike>typename enable_if&lt;is_error_code_enum&lt;ErrorConditionEnum&gt;::value&gt;::type * = 0</strike></font>);

...

template &lt;<strike><font color="#FF0000">class</font></strike> ErrorConditionEnum <font color="#0099CC"><u>E</u></font>&gt;
  <strike><font color="#FF0000">typename enable_if&lt;is_error_condition_enum&lt;Error</font></strike><font color="#FF0000"><strike>Condition</strike></font><strike><font color="#FF0000">Enum&gt;::value&gt;::type&amp;</font></strike> <font color="#0099CC"><u>error_condition&amp;</u></font>
    operator=(<strike><font color="#FF0000">Error</font></strike><font color="#FF0000"><strike>Condition</strike></font><strike><font color="#FF0000">Enum</font></strike> <font color="#0099CC"><u>E</u></font> e);</pre>
</blockquote>
<p><i>Change 19.4.3.2 Class error_condition constructors [syserr.errcondition.constructors]:</i></p>
<blockquote>
  <pre>template &lt;<strike><font color="#FF0000">class</font></strike> ErrorConditionEnum <font color="#0099CC"><u>E</u></font>&gt;
&nbsp;&nbsp; error_condition(<strike><font color="#FF0000">Error</font></strike><font color="#FF0000"><strike>Condition</strike></font><strike><font color="#FF0000">Enum</font></strike> <font color="#0099CC"><u>E</u></font> e<font color="#FF0000"><strike>,
</strike>&nbsp;&nbsp;&nbsp;&nbsp; <strike>typename enable_if&lt;is_error_code_enum&lt;ErrorConditionEnum&gt;::value&gt;::type * = 0</strike></font>);</pre>
</blockquote>
<p><i>Change 19.4.3.3 Class error_condition modifiers [syserr.errcondition.modifiers]:</i></p>
<blockquote>
  <pre>template &lt;<strike><font color="#FF0000">class</font></strike> ErrorConditionEnum <font color="#0099CC"><u>E</u></font>&gt;
  <strike><font color="#FF0000">typename enable_if&lt;is_error_condition_enum&lt;Error</font></strike><font color="#FF0000"><strike>Condition</strike></font><strike><font color="#FF0000">Enum&gt;::value&gt;::type&amp;</font></strike> <font color="#0099CC"><u>error_condition&amp;</u></font>
    operator=(<strike><font color="#FF0000">Error</font></strike><font color="#FF0000"><strike>Condition</strike></font><strike><font color="#FF0000">Enum</font></strike> <font color="#0099CC"><u>E</u></font> e);</pre>
</blockquote>
<h2>Bibliography</h2>
<p>[<a name="1">1</a>] D.&nbsp;Gregor, B.&nbsp;Stroustrup, J.&nbsp;Siek, J.&nbsp;Widman. Proposed 
Wording for Concepts (Revision 5). Technical Report N2617=08-0127, ISO/IEC JTC 1, Information Technology, Subcommittee SC 22, 
Programming Language C++, May 2008.</p>

<hr>

</body>

</html>