<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>TR2 Diagnostics Enhancements</title>
</head>

<body>

<p>Doc. no.&nbsp;&nbsp; <span style="background-color: #FFFF00">N2241</span>=07-0101<br>
Date:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<!--webbot bot="Timestamp" s-type="EDITED" s-format="%Y-%m-%d" startspan -->2007-04-19<!--webbot bot="Timestamp" endspan i-checksum="12285" --><br>
Project:&nbsp;&nbsp;&nbsp;&nbsp; Programming Language C++<br>
Reply to:&nbsp;&nbsp; Beman Dawes &lt;<a href="mailto:bdawes@acm.org">bdawes@acm.org</a>&gt;</p>

<h1>Diagnostics Enhancements for C++0x (Rev. 1)</h1>

<p><a href="#Introduction">Introduction</a><br>
<a href="#Design_Rationale">Design Rationale</a><br>
<a href="#History">History</a><br>
<a href="#Acknowledgements">Acknowledgements</a><br>
<a href="#Proposed">Proposed changes to the Working Paper</a><br>
&nbsp;&nbsp;&nbsp; <a href="#system_error">Header &lt;system_error&gt;</a><br>
&nbsp;&nbsp;&nbsp; <a href="#system_error">Class system_error</a><br>
&nbsp;&nbsp;&nbsp; <a href="#error_category">Class error_category</a><br>
&nbsp;&nbsp;&nbsp; <a href="#error_code">Class error_code</a></p>
<h2><a name="Introduction">Introduction</a></h2>
<p>Error conditions originating from the operating system or other low-level 
application program interfaces (API's) are typically reported via an integer 
representing an error code. On the other hand, the preferred mechanism for C++ libraries, 
including the standard library, is to report such errors by throwing an 
exception. Experience with the progenitors of the Filesystem Library (<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1975.html">N1975</a>), 
the Networking Library (<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2054.pdf">N2054</a>), 
and with similar <a href="http://www.boost.org">Boost</a> libraries has shown 
that such exceptions need to include the original error code to allow programs 
to undertake error-condition specific recovery actions.</p>
<p>That experience also found that while exceptions are the preferred default 
error code reporting mechanism, programs that use libraries dependent on 
low-level  API's&nbsp;need overloads reporting error conditions via error 
code arguments and/or return values rather than via throwing exceptions. 
Otherwise, when errors are not exceptional occurrences 
and must be dealt with as they arise, programs become littered with try/catch 
blocks, unreadable, and very inefficient.</p>
<p>The proposed diagnostic enhancements were originally slated for TR2 (<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2066.html">N2066</a>). They are 
now proposed for C++0x so that they can be used by C++0x threads libraries.</p>
<h2><a name="Design_Rationale">Design Rationale</a></h2>
<p>These diagnostic components are packaged in a single header to follow the 
standard library's practice of  large granularity headers. The components are not simply 
added to <code>&lt;stdexcept&gt;</code> to hold down dependencies in <code>&lt;stdexcept&gt;</code>.</p>
<p>The header is named <code>&lt;system_error&gt;</code> to emphasize the role its 
contents play, and to emphasize the <code>system_error</code> exception class. 
This is also intended to present class <code>error_code</code> as an adjunct to 
error reporting by exception, rather than a completely separate error handling 
mechanism.</p>
<p><code>error_code</code>&nbsp; is designed as a value type so it can be copied 
without slicing and does not requiring heap allocation, but to 
have polymorphic behavior based on the error category. This is achieved by 
abstract base class <code>error_category</code> supplying the polymorphic 
behavior, and <code>error_code</code> containing a pointer to an object of a 
type derived from <code>error_category</code>.</p>
<p>The <code>operator&lt;&lt;</code> overload for <code>error_code</code> eliminates a 
misleading conversion to bool in code like <code>cout &lt;&lt; ec</code>, where <code>
ec</code> is of type <code>error_code</code>. It is also useful in its own 
right.</p>
<h2><a name="History">History</a></h2>
<p><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1975.html">
N1975</a>, Filesystem Library Proposal for TR2, accepted for Library Technical 
Report 2 (TR2) at the Berlin meeting, included additional components to 
supplement the Standard Library's Diagnostics clause. Since then, these error 
reporting components have received wider public scrutiny and enhancements have 
been made to the design. The enhanced version has been used by N2054, Networking 
Library Proposal for TR2, demonstrating that these error reporting components 
are useful beyond the original Filesystem Library.</p>
<p>The original proposal viewed error categories as a binary choice between
<code>errno</code> (i.e. POSIX-style) and the native operating system's error 
codes. The proposed components now allow as many additional error categories 
as are needed by either implementations or by users. The need to support 
additional error categories, for example, occurs in some networking library 
implementations because they are built on top of the POSIX <code>getaddrinfo</code> API that uses error codes 
not based on <code>errno</code>.</p>
  <h2><a name="Acknowledgements">Acknowledgements</a></h2>
  <p>Christopher Kohlhoff and Peter Dimov made important contributions to the 
  design. Comments and suggestions were also received from Pavel Vozenilek, 
  Gennaro Prota, Dave Abrahams, Jeff Garland, Iain Hanson, Oliver Kowalke, and 
  Oleg Abrosimov. Christopher Kohlhoff suggested several improvements to the 
  N2066 paper. Johan Nilsson's comments led to several of the refinements in 
  N2066 </p>

<h2><a name="Proposed">Proposed</a> changes to the Working Paper</h2>

<p><i>Add to Chapter 19, Diagnostics library [diagnostics], paragraph 2, an 
additional line in the Diagnostics library summary table, so it reads:</i></p>
<p align="left"><span style="font-weight: 400">Table 26: Diagnostics library 
summary</span></p>
<table border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="60%">
  <tr>
    <td width="50%" align="center"><b>Subclause</b></td>
    <td width="50%" align="center"><b>Header(s)</b></td>
  </tr>
  <tr>
    <td width="50%"><span style="font-weight: 400">19.1 Exception classes</span></td>
    <td width="50%"><span style="font-weight: 400"><code>&lt;stdexcept&gt;</code></span></td>
  </tr>
  <tr>
    <td width="50%"><span style="font-weight: 400">19.2 Assertions</span></td>
    <td width="50%"><span style="font-weight: 400"><code>&lt;cassert&gt;</code></span></td>
  </tr>
  <tr>
    <td width="50%"><span style="font-weight: 400">19.3 Error numbers</span></td>
    <td width="50%"><span style="font-weight: 400"><code>&lt;cerrno&gt;</code></span></td>
  </tr>
  <tr>
    <td width="50%"><u><font color="#228822">19.4 System error support</font></u></td>
    <td width="50%"><u><font color="#228822"><code>&lt;system_error&gt;</code></font></u></td>
  </tr>
</table>
<p><i>Change 19.3, Error numbers [errno], as indicated:</i></p>
<p>Header &lt;cerrno&gt; (Table 28):</p>
<p>Table 28: Header &lt;cerrno&gt; synopsis</p>
<table border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%">
  <tr>
    <td width="100%"><b>Type:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
    Name(s)</b></td>
  </tr>
  <tr>
    <td width="100%"><b>Macros:</b> <u><font color="#228822">E2BIG EACCES 
    EADDRINUSE EADDRNOTAVAIL EAFNOSUPPORT EAGAIN EALREADY EBADF EBADMSG EBUSY 
    ECANCELED ECHILD ECONNABORTED ECONNREFUSED ECONNRESET EDEADLK EDESTADDRREQ</font></u> 
    EDOM <u><font color="#228822">EEXIST EFAULT EFBIG EHOSTUNREACH EIDRM</font></u> 
    EILSEQ <u><font color="#228822">EINPROGRESS EINTR EINVAL EIO EISCONN EISDIR 
    ELOOP EMFILE EMLINK EMSGSIZE ENAMETOOLONG ENETDOWN ENETRESET ENETUNREACH 
    ENFILE ENOBUFS ENODATA ENODEV ENOENT ENOEXEC ENOLCK ENOLINK ENOMEM ENOMSG 
    ENOPROTOOPT ENOSPC ENOSR ENOSTR ENOSYS ENOTCONN ENOTDIR ENOTEMPTY 
    ENOTRECOVERABLE ENOTSOCK 
    ENOTSUP ENOTTY ENXIO EOPNOTSUPP EOTHER EOVERFLOW EOWNERDEAD EPERM EPIPE EPROTO 
    EPROTONOSUPPORT EPROTOTYPE</font></u> ERANGE <u><font color="#228822">EROFS 
    ESPIPE ESRCH ETIME ETIMEDOUT ETXTBSY EWOULDBLOCK EXDEV</font></u> errno</td>
  </tr>
</table>
<p>The contents are the same as the <strike><font color="#FF0000">Standard C 
library</font></strike> <font color="#228822"><u>POSIX</u></font> header <code>&lt;errno.h&gt;</code>, 
except that <code>errno</code> shall be defined as a macro<u><font color="#228822">, 
and an additional macro <code>EOTHER</code> shall be defined to represent errors 
not specified by the POSIX standard</font></u>. <u><font color="#228822"><i>
[Note:</i> The intent is to remain in close alignment with the POSIX standard.
<i>--end note]</i></font></u></p>
<p><i>Add to Chapter 19, Diagnostics library [diagnostics], the following new 
subclause. The Project Editor may wish to identify it as </i>19.4 System error support [sys_err_support.code]<i>.</i></p>
<p>This subclause describes components that the standard library and C++ 
programs may use to report error conditions originating from the operating 
system or other low-level application program interfaces.</p>
<p>Component described in this subclause shall not change the value of <code>
errno</code> ([errno]). Implementations are encouraged but not required to leave 
unchanged the error states provided by other libraries.</p>
<h3><a name="Header">Header</a> &lt;system_error&gt;</h3>
<pre>namespace std
{
  class <a href="#system_error">system_error</a>;
  class <a href="#error_code">error_code</a>;
  class <a href="#error_category">error_category</a>;

  extern const error_category&amp; posix_category;
  extern const error_category&amp; native_category;

  template &lt;class charT, class traits&gt;
    std::basic_ostream&lt;charT,traits&gt;&amp;
      operator&lt;&lt;(basic_ostream&lt;charT,traits&gt;&amp; os, const error_code &amp; ec);

  size_t hash_value(const error_code &amp; ec);</pre>
<pre>  enum posix_errno
  {
    address_family_not_supported,
    address_in_use,
    address_not_available,
    already_connected,
    argument_list_too_long,
    argument_out_of_domain,
    bad_address,
    bad_file_descriptor,
    bad_message,
    broken_pipe,
    connection_aborted,
    connection_already_in_progress,
    connection_refused,
    connection_reset,
    cross_device_link,
    destination_address_required,
    device_or_resource_busy,
    directory_not_empty,
    executable_format_error,
    file_exists,
    file_too_large,
    filename_too_long,
    function_not_supported,
    host_unreachable,
    identifier_removed,
    illegal_byte_sequence,
    inappropriate_io_control_operation,
    interrupted,
    invalid_argument,
    invalid_seek,
    io_error,
    is_a_directory,
    message_size,
    network_down,
    network_reset,
    network_unreachable,
    no_buffer_space,
    no_child_process,
    no_link,
    no_lock_available,
    no_message_available,
    no_message,
    no_protocol_option,
    no_space_on_device,
    no_stream_resources,
    no_such_device_or_address,
    no_such_device,
    no_such_file_or_directory,
    no_such_process,
    not_a_directory,
    not_a_socket,
    not_a_stream,
    not_connected,
    not_enough_memory,
    not_supported,
    operation_canceled,
    operation_in_progress,
    operation_not_permitted,
    operation_not_supported,
    operation_would_block,
    other,
    permission_denied,
    protocol_error,
    protocol_not_supported,
    read_only_file_system,
    resource_deadlock_would_occur,
    resource_unavailable_try_again,
    result_out_of_range,
    stream_timeout,
    text_file_busy,
    timed_out,
    too_many_files_open_in_system,
    too_many_files_open,
    too_many_links,
    too_many_synbolic_link_levels,
    value_too_large,
    wrong_protocol_type
  };

  bool operator==(const error_code&amp; ec, posix_errno en);
  bool operator==(posix_errno en, const error_code&amp; ec);
  bool operator!=(const error_code&amp; ec, posix_errno en);
  bool operator!=(posix_errno en, const error_code&amp; ec);
}</pre>
<h3>Error category objects</h3>
<p>Predefined objects <code>posix_category</code> 
and <code>native_category</code> identify portable and native error 
codes, respectively.</p>
<h3>Non-member functions</h3>
<pre>template &lt;class charT, class traits&gt;
  std::basic_ostream&lt;charT,traits&gt;&amp;
    operator&lt;&lt;(basic_ostream&lt;charT,traits&gt;&amp; os, const error_code &amp; ec);</pre>
<blockquote>
<p><i>Effects:</i> <code>os &lt;&lt; ec.category().name() &lt;&lt; ':' &lt;&lt; ec.value()</code>.</p>
<p><i>Returns:</i> <code>os</code>.</p>
</blockquote>
<pre>size_t <a name="hash_value">hash_value</a>( const error_code&amp; ec );</pre>
<blockquote>
  <p><i>Returns: </i>&nbsp;A hash value representing <code>ec</code>.</p>
</blockquote>

<h3>enum posix_errno</h3>
<p>The meaning and value of each <code>posix_errno</code> element shall correspond to the equivalent macro from 
header <code>&lt;cerrno&gt;</code>, as defined in the table below.</p>

<blockquote>  
<table border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" height="2077">
  <tr>
    <td align="center" height="19"><i><b>Name</b></i></td>
    <td align="center" height="19"><b><i>&lt;cerrno&gt;</i></b><i><b> macro</b></i></td>
  </tr>
  <tr>
    <td height="16"><code>address_family_not_supported</code></td>
    <td height="16">
      <code>EAFNOSUPPORT </code>
    </td>
  </tr>
  <tr>
    <td height="16"><code>address_in_use</code></td>
    <td height="16">
      <code>EADDRINUSE </code>
    </td>
  </tr>
  <tr>
    <td height="16"><code>address_not_available</code></td>
    <td height="16">
      <code>EADDRNOTAVAIL </code>
    </td>
  </tr>
  <tr>
    <td height="16"><code>already_connected</code></td>
    <td height="16">
      <code>EISCONN </code>
    </td>
  </tr>
  <tr>
    <td height="16"><code>argument_list_too_long</code></td>
    <td height="16">
      <code>E2BIG </code>
    </td>
  </tr>
  <tr>
    <td height="16"><code>argument_out_of_domain</code></td>
    <td height="16">
      <code>EDOM </code>
    </td>
  </tr>
  <tr>
    <td height="16"><code>bad_address</code></td>
    <td height="16">
      <code>EFAULT </code>
    </td>
  </tr>
  <tr>
    <td height="16"><code>bad_file_descriptor</code></td>
    <td height="16">
      <code>EBADF </code>
    </td>
  </tr>
  <tr>
    <td height="16"><code>bad_message</code></td>
    <td height="16">
      <code>EBADMSG </code>
    </td>
  </tr>
  <tr>
    <td height="16"><code>broken_pipe</code></td>
    <td height="16">
      <code>EPIPE </code>
    </td>
  </tr>
  <tr>
    <td height="16"><code>connection_aborted</code></td>
    <td height="16">
      <code>ECONNABORTED </code>
    </td>
  </tr>
  <tr>
    <td height="16"><code>connection_already_in_progress</code></td>
    <td height="16">
      <code>EALREADY </code>
    </td>
  </tr>
  <tr>
    <td height="16"><code>connection_refused</code></td>
    <td height="16">
      <code>ECONNREFUSED </code>
    </td>
  </tr>
  <tr>
    <td height="16"><code>connection_reset</code></td>
    <td height="16">
      <code>ECONNRESET </code>
    </td>
  </tr>
  <tr>
    <td height="16"><code>cross_device_link</code></td>
    <td height="16">
      <code>EXDEV </code>
    </td>
  </tr>
<tr>
  <td height="16"><code>destination_address_required</code></td>
  <td height="16">
    <code>EDESTADDRREQ </code>
  </td>
</tr>
<tr>
  <td height="16"><code>device_or_resource_busy</code></td>
  <td height="16">
    <code>EBUSY </code>
  </td>
</tr>
<tr>
  <td height="16"><code>directory_not_empty</code></td>
  <td height="16">
    <code>ENOTEMPTY </code>
  </td>
</tr>
<tr>
  <td height="16"><code>executable_format_error</code></td>
  <td height="16">
    <code>ENOEXEC </code>
  </td>
</tr>
<tr>
  <td height="16"><code>file_exists</code></td>
  <td height="16">
    <code>EEXIST </code>
  </td>
</tr>
<tr>
  <td height="16"><code>file_too_large</code></td>
  <td height="16">
    <code>EFBIG </code>
  </td>
</tr>
<tr>
  <td height="16"><code>filename_too_long</code></td>
  <td height="16">
    <code>ENAMETOOLONG </code>
  </td>
</tr>
<tr>
  <td height="16"><code>function_not_supported</code></td>
  <td height="16">
    <code>ENOSYS </code>
  </td>
</tr>
<tr>
  <td height="16"><code>host_unreachable</code></td>
  <td height="16">
    <code>EHOSTUNREACH </code>
  </td>
</tr>
<tr>
  <td height="16"><code>identifier_removed</code></td>
  <td height="16">
    <code>EIDRM </code>
  </td>
</tr>
<tr>
  <td height="16"><code>illegal_byte_sequence</code></td>
  <td height="16">
    <code>EILSEQ </code>
  </td>
</tr>
<tr>
  <td height="16"><code>inappropriate_io_control_operation</code></td>
  <td height="16">
    <code>ENOTTY </code>
  </td>
</tr>
<tr>
  <td height="16"><code>interrupted</code></td>
  <td height="16">
    <code>EINTR </code>
  </td>
</tr>
<tr>
  <td height="16"><code>invalid_argument</code></td>
  <td height="16">
    <code>EINVAL </code>
  </td>
</tr>
<tr>
  <td height="16"><code>invalid_seek</code></td>
  <td height="16">
    <code>ESPIPE </code>
  </td>
</tr>
<tr>
  <td height="16"><code>io_error</code></td>
  <td height="16">
    <code>EIO </code>
  </td>
</tr>
<tr>
  <td height="16"><code>is_a_directory</code></td>
  <td height="16">
    <code>EISDIR </code>
  </td>
</tr>
<tr>
  <td height="16"><code>message_size</code></td>
  <td height="16">
    <code>EMSGSIZE </code>
  </td>
</tr>
<tr>
  <td height="16"><code>network_down</code></td>
  <td height="16">
    <code>ENETDOWN </code>
  </td>
</tr>
<tr>
  <td height="16"><code>network_reset</code></td>
  <td height="16">
    <code>ENETRESET </code>
  </td>
</tr>
<tr>
  <td height="16"><code>network_unreachable</code></td>
  <td height="16">
    <code>ENETUNREACH </code>
  </td>
</tr>
<tr>
  <td height="16"><code>no_buffer_space</code></td>
  <td height="16">
    <code>ENOBUFS </code>
  </td>
</tr>
<tr>
  <td height="16"><code>no_child_process</code></td>
  <td height="16">
    <code>ECHILD </code>
  </td>
</tr>
<tr>
  <td height="16"><code>no_link</code></td>
  <td height="16">
    <code>ENOLINK </code>
  </td>
</tr>
<tr>
  <td height="16"><code>no_lock_available</code></td>
  <td height="16">
    <code>ENOLCK </code>
  </td>
</tr>
<tr>
  <td height="16"><code>no_message_available</code></td>
  <td height="16">
    <code>ENODATA </code>
  </td>
</tr>
<tr>
  <td height="16"><code>no_message</code></td>
  <td height="16">
    <code>ENOMSG </code>
  </td>
</tr>
<tr>
  <td height="16"><code>no_protocol_option</code></td>
  <td height="16">
    <code>ENOPROTOOPT </code>
  </td>
</tr>
<tr>
  <td height="16"><code>no_space_on_device</code></td>
  <td height="16">
    <code>ENOSPC </code>
  </td>
</tr>
<tr>
  <td height="16"><code>no_stream_resources</code></td>
  <td height="16">
    <code>ENOSR </code>
  </td>
</tr>
<tr>
  <td height="16"><code>no_such_device_or_address</code></td>
  <td height="16">
    <code>ENXIO </code>
  </td>
</tr>
<tr>
  <td height="16"><code>no_such_device</code></td>
  <td height="16">
    <code>ENODEV </code>
  </td>
</tr>
<tr>
  <td height="16"><code>no_such_file_or_directory</code></td>
  <td height="16">
    <code>ENOENT </code>
  </td>
</tr>
<tr>
  <td height="16"><code>no_such_process</code></td>
  <td height="16">
    <code>ESRCH </code>
  </td>
</tr>
<tr>
  <td height="16"><code>not_a_directory</code></td>
  <td height="16">
    <code>ENOTDIR </code>
  </td>
</tr>
  <tr>
  <td height="16"><code>not_a_socket</code></td>
  <td height="16">
    <code>ENOTSOCK </code>
  </td>
  </tr>
<tr>
  <td height="16"><code>not_a_stream</code></td>
  <td height="16">
    <code>ENOSTR </code>
  </td>
</tr>
<tr>
  <td height="16"><code>not_connected</code></td>
  <td height="16">
    <code>ENOTCONN </code>
  </td>
</tr>
<tr>
  <td height="16"><code>not_enough_memory</code></td>
  <td height="16">
    <code>ENOMEM </code>
  </td>
</tr>
<tr>
  <td height="16"><code>not_supported</code></td>
  <td height="16">
    <code>ENOTSUP </code>
  </td>
</tr>
<tr>
  <td height="16"><code>operation_canceled</code></td>
  <td height="16">
    <code>ECANCELED </code>
  </td>
</tr>
<tr>
  <td height="16"><code>operation_in_progress</code></td>
  <td height="16">
    <code>EINPROGRESS </code>
  </td>
</tr>
<tr>
  <td height="16"><code>operation_not_permitted</code></td>
  <td height="16">
    <code>EPERM </code>
  </td>
</tr>
<tr>
  <td height="16"><code>operation_not_supported</code></td>
  <td height="16">
    <code>EOPNOTSUPP </code>
  </td>
</tr>
<tr>
  <td height="16"><code>operation_would_block</code></td>
  <td height="16">
    <code>EWOULDBLOCK </code>
  </td>
</tr>
<tr>
  <td height="16"><code>other</code></td>
  <td height="16">
    <code>EOTHER</code></td>
</tr>
<tr>
  <td height="16"><code>owner_dead</code></td>
  <td height="16">
    <code>EOWNERDEAD</code></td>
</tr>
<tr>
  <td height="16"><code>permission_denied</code></td>
  <td height="16">
    <code>EACCES </code>
  </td>
</tr>
<tr>
  <td height="16"><code>protocol_error</code></td>
  <td height="16">
    <code>EPROTO </code>
  </td>
</tr>
<tr>
  <td height="16"><code>protocol_not_supported</code></td>
  <td height="16">
    <code>EPROTONOSUPPORT </code>
  </td>
</tr>
<tr>
  <td height="16"><code>read_only_file_system</code></td>
  <td height="16">
    <code>EROFS </code>
  </td>
</tr>
<tr>
  <td height="16"><code>resource_deadlock_would_occur</code></td>
  <td height="16">
    <code>EDEADLK </code>
  </td>
</tr>
<tr>
  <td height="16"><code>resource_unavailable_try_again</code></td>
  <td height="16">
    <code>EAGAIN </code>
  </td>
</tr>
<tr>
  <td height="16"><code>result_out_of_range</code></td>
  <td height="16">
    <code>ERANGE </code>
  </td>
</tr>
<tr>
  <td height="19"><code>state_not_recoverable</code></td>
  <td height="19">
    <code>ENOTRECOVERABLE</code></td>
</tr>
<tr>
  <td height="16"><code>stream_timeout</code></td>
  <td height="16">
    <code>ETIME </code>
  </td>
</tr>
<tr>
  <td height="1"><code>text_file_busy</code></td>
  <td height="1">
    <code>ETXTBSY </code>
  </td>
</tr>
<tr>
  <td height="16"><code>timed_out</code></td>
  <td height="16">
    <code>ETIMEDOUT </code>
  </td>
</tr>
<tr>
  <td height="16"><code>too_many_files_open_in_system</code></td>
  <td height="16">
    <code>ENFILE </code>
  </td>
</tr>
<tr>
  <td height="16"><code>too_many_files_open</code></td>
  <td height="16">
    <code>EMFILE </code>
  </td>
</tr>
<tr>
  <td height="16"><code>too_many_links</code></td>
  <td height="16">
    <code>EMLINK </code>
  </td>
</tr>
<tr>
  <td height="16"><code>too_many_synbolic_link_levels</code></td>
  <td height="16">
    <code>ELOOP </code>
  </td>
</tr>
<tr>
  <td height="16"><code>value_too_large</code></td>
  <td height="16">
    <code>EOVERFLOW </code>
  </td>
</tr>
<tr>
  <td height="16"><code>wrong_protocol_type</code></td>
  <td height="16">
    <code>EPROTOTYPE </code>
  </td>
</tr>
</table>
</blockquote>

<p><i>[Note:</i> <code>other</code> is used to indicate errors 
that have no POSIX equivalent. <i>--end note]</i></p>

<h3>Class <code>
<a name="system_error">system_error</a></code></h3>
<p>The class <code>system_error</code> defines the type of objects thrown as 
exceptions to report error conditions that have an associated error code. Such 
error conditions typically originate from the operating system or other 
low-level application program interfaces.</p>
<pre>namespace std
{
  class system_error : public std::runtime_error
  {
  public:
    system_error(error_code ec, const std::string&amp; what_arg);
    system_error(error_code::value_type ev, const error_category&amp; ecat,
                 const std::string&amp; what_arg);

    const error_code&amp; code() const throw();
    const char*       what() const throw();
  };
}</pre>
<pre>system_error(error_code ec, const std::string&amp; what_arg);</pre>
<blockquote>
  <p><i>Effects:</i> Constructs an object of class <code>system_error</code>.</p>
  <p><i>Postcondition:</i> <code>code() == ec <br>
&nbsp; &amp;&amp; strcmp( this-&gt;runtime_error::what(), what_arg.c_str()) == 0</code></p>
</blockquote>
<pre>system_error(error_code::value_type ev, const error_category&amp; ecat,
             const std::string&amp; what_arg);</pre>
<blockquote>
  <p><i>Effects:</i> Constructs an object of class <code>system_error</code>.</p>
  <p><i>Postcondition:</i> <code>code() == error_code(ev, ecat)<br>
&nbsp; &amp;&amp; strcmp( this-&gt;runtime_error::what(), what_arg.c_str()) == 0</code></p>
</blockquote>
<pre>const error_code&amp; code() const;</pre>
<blockquote>
  <p><i>Returns:</i> <code>ec</code> or <code>error_code(ev, ecat)</code>, from 
  the constructor, as appropriate.</p>
</blockquote>
<pre>const char* what() const;</pre>
<blockquote>
  <p><i>Returns: </i>A string incorporating <code>
  this-&gt;runtime_error::what()</code> and <code>
  code.message()</code>.</p>
  <p>[<i>Note:</i> One possible implementation would be:</p>
  <blockquote>
    <pre>if (msg.empty())
{
  try
  {
    msg = this-&gt;runtime_error::what();
    if ( code() )
    {
      if ( !msg.empty() ) msg += &quot;: &quot;;
      msg += code().message();
    }
  }
  catch (...) { return runtime_error::what(); }
}
return msg.c_str();</pre>
  </blockquote>
    <p><i>--end note</i>]</p>
</blockquote>
<h3>Class <code><a name="error_category">error_category</a></code></h3>
<p>The class <code>error_category</code> defines the base class for types used 
to identify the source and encoding of a particular category of error code.</p>
<p><i>[Note:</i> Classes may be derived from <code>error_category</code> 
to support additional categories of errors. <i>--end note]</i></p>
<pre>namespace std
{
  class error_category
  {
  public:
    virtual const std::string &amp; name() const=0;
    virtual posix_errno posix(error_code::value_type ev) const=0;
    virtual string message(error_code::value_type ev) const=0;
    virtual wstring wmessage(error_code::value_type ev) const=0;

    bool operator==(const error_category&amp; rhs) const;
    bool operator!=(const error_category&amp; rhs) const;
  };
}</pre>
<h3>Class <code>error_category</code> virtual members</h3>
<p>Classes derived from <code>error_category</code> shall behave as specified in 
this subclause.</p>
<pre>virtual const std::string &amp; name() const=0;</pre>
<blockquote>
  <p><i>Returns: </i>a string naming the error category.</p>
  <p><i>Throws:</i> Nothing.</p>
</blockquote>
<pre>virtual posix_errno posix(error_code::value_type ev) const=0;</pre>
<blockquote>
  <p><i>Returns:</i> A <code>posix_errno</code> that corresponds to <code>ev</code> if such a corresponding POSIX error 
  number exists, otherwise <code>other</code>.</p>
<p><i>[Note:</i>&nbsp; Since the value of <code>ev</code> is not bounded, the 
intent is that implementations translate 
commonly encountered values to the equivalent POSIX error number and translate the rest to
<code>other</code><i>.</i> <i>--end note]</i></p>
  <p><i>Throws:</i> Nothing.</p>
</blockquote>
<pre>virtual string message(error_code::value_type ev) const=0;</pre>
<blockquote>
  <p><i>Returns:</i> A string that describes the error condition denoted by
  <code>ev</code>.</p>
<p><i>[Note:</i> The intent is to return a locale sensitive string that describes the error 
corresponding to <code>ev</code>.&nbsp; <i>--end note.]</i></p>
  <p><i>Throws:</i> Nothing.</p>
</blockquote>
<pre>virtual wstring wmessage(error_code::value_type ev) const=0;</pre>
<blockquote>
  <p><i>Returns:</i> A string that describes the error condition denoted by
  <code>ev</code>.</p>
<p><i>[Note:</i> The intent is to return a locale sensitive string that describes the error 
corresponding to <code>ev</code>.&nbsp; <i>--end note.]</i></p>
  <p><i>Throws:</i> Nothing.</p>
</blockquote>
<h3>Class <code>error_category</code> non-virtual members</h3>
<p><code>bool operator==(const error_category&amp; rhs) const;</code></p>
<blockquote>
<p><i>Returns:</i> <code>this == &amp;rhs</code>.</p>
</blockquote>
<p><code>bool operator!=(const error_category&amp; rhs) const;</code></p>
<blockquote>
<p><i>Returns:</i> <code>this != &amp;rhs</code>.</p>
</blockquote>
<h3>Class <code>
<a name="error_code">error_code</a></code></h3>
<p>The class <code>error_code</code> defines the type of objects used to hold error code values, such as those originating from 
the operating system or other low-level application program interfaces.</p>
<p><i>[Note:</i> Class <code>error_code</code> as an adjunct to 
error reporting by exception, rather than a completely separate error handling 
mechanism. <i>--end note.]</i></p>
<pre>namespace std
{
  class error_code
  {
  public:
    typedef int_least32_t value_type;

    // constructors:
    error_code();
    error_code(value_type val, const error_category&amp; cat);
    error_code(posix_errno val);

    // modifiers:
    void assign(value_type val, const error_category&amp; cat);
    error_code&amp; operator=(posix_errno val);
    void clear();

    // observers:
    value_type             value() const;
    const error_category&amp;  category() const;
    posix_errno            posix() const;
    string                 message() const;
    wstring                wmessage() const;
    operator <i>unspecified-bool-type</i>() const;

    // relationals:
    bool operator==(const error_code&amp; rhs) const;
    bool operator!=(const error_code&amp; rhs) const;

  private:
    value_type            _val; // <b><i>for exposition only</i></b>
    const error_category* _cat; // <b><i>for exposition only</i></b>
  };
}</pre>
<h3>Class <code>
error_code</code> members</h3>
<pre>error_code();</pre>
<blockquote>
  <p><i>Effects: </i>Constructs an object of type <code>error_code</code>.</p>
  <p><i>Postconditions:</i> <code>_val == 0 &amp;&amp; _cat == &amp;posix_category</code>.</p>
  <p><i>Throws:</i> Nothing.</p>
</blockquote>
<pre>error_code(value_type val, const error_category&amp; cat);</pre>
<blockquote>
  <p><i>Effects: </i>Constructs an object of type <code>error_code</code>.</p>
  <p><i>Postconditions:</i> <code>_val == val &amp;&amp; _cat == &amp;cat</code>.</p>
  <p><i>Throws:</i> Nothing.</p>
</blockquote>
<pre>error_code(posix_errno val);</pre>
<blockquote>
  <p><i>Effects: </i>Constructs an object of type <code>error_code</code>.</p>
  <p><i>Postconditions:</i> <code>_val == static_cast&lt;value_type&gt;(val) &amp;&amp; _cat == &amp;posix_category</code>.</p>
  <p><i>Throws:</i> Nothing.</p>
</blockquote>
<pre>void assign(value_type val, const error_category&amp; cat);</pre>
<blockquote>
  <p><i>Postconditions:</i> <code>_val == val &amp;&amp; _cat == &amp;cat</code>.</p>
  <p><i>Throws:</i> Nothing.</p>
</blockquote>
<pre>error_code&amp; operator=(posix_errno val);</pre>
<blockquote>
  <p><i>Postconditions:</i> <code>_val == static_cast&lt;value_type&gt;(val) &amp;&amp; _cat == &amp;posix_category</code>.</p>
  <p><i>Throws:</i> Nothing.</p>
</blockquote>
  <p><code>value_type value() const;</code></p>
<blockquote>
<p><i>Returns:</i> <code>_val</code>.</p>
  <p><i>Throws:</i> Nothing.</p>
</blockquote>
  <p><code>error_category category() const;</code></p>
<blockquote>
<p><i>Returns:</i> <code>_cat</code>.</p>
  <p><i>Throws:</i> Nothing.</p>
</blockquote>
  <p><code>posix_errno posix() const;</code></p>
<blockquote>
<p><i>Returns:</i>&nbsp; <code>category().posix(value())</code>.</p>
  <p><i>Throws:</i> Nothing.</p>
</blockquote>
  <p><code>string message() const;</code></p>
<blockquote>
<p><i>Returns:</i>&nbsp; <code>category().message(value())</code>.</p>
  <p><i>Throws:</i> Nothing.</p>
</blockquote>
  <p><code>wstring wmessage() const;</code></p>
<blockquote>
<p><i>Returns:</i>&nbsp; <code>category().wmessage(value())</code>.</p>
  <p><i>Throws:</i> Nothing.</p>
</blockquote>
<p><code>operator <i>unspecified-bool-type</i>() const;</code></p>
<blockquote>
<p><i>Returns:</i> if <code>value() != value_type()</code>, returns a value that will evaluate
<code>true</code> in a boolean context; otherwise, returns a value that will 
evaluate <code>false</code> in a boolean context. The value type returned shall 
not be convertible to <code>int</code>.</p>
<p><i>Throws:</i> nothing.</p>
<p>[<i>Note: </i>This conversion can be used in contexts where a <code>bool</code> 
is expected (e.g., an <code>if</code> condition); however, implicit conversions 
(e.g., to <code>int</code>) that can occur with <code>bool</code> are not 
allowed, eliminating some sources of user error. One possible implementation 
choice for this type is pointer-to-member. <i>—end note </i>]</p>
</blockquote>
<p><code>bool operator==(const error_code&amp; rhs) const;</code></p>
<blockquote>
<p><i>Returns:</i> <code>value() == rhs.value() &amp;&amp; category() == rhs.category()</code>.</p>
  <p><i>Throws:</i> Nothing.</p>
</blockquote>
<p><code>bool operator!=(const error_code&amp; rhs) const;</code></p>
<blockquote>
<p><i>Returns:</i> <code>!(*this == rhs)</code>.</p>
  <p><i>Throws:</i> Nothing.</p>
</blockquote>
  <h3>non-member functions</h3>
  <p><code>bool operator==(const error_code&amp; ec, posix_errno en);<br>
  bool operator==(posix_errno en, const error_code&amp; ec);</code></p>
<blockquote>
  <p><i>Returns:</i> <code>ec.value() == static_cast&lt;error_code::value_type&gt;(en) 
  &amp;&amp; ec.category() == &amp;posix_category</code></p>
  <p><i>Throws:</i> Nothing.</p>
</blockquote>
  <p><code>bool operator!=(const error_code&amp; ec, posix_errno en);<br>
  bool operator!=(posix_errno en, const error_code&amp; ec);</code></p>
<blockquote>
  <p><i>Returns:</i> <code>!(ec==en)</code></p>
  <p><i>Throws:</i> Nothing.</p>
</blockquote>
<hr>

</body>

</html>