System/FileSystem: merge from trunk to fix #7278.

[SVN r83550]
This commit is contained in:
Vicente J. Botet Escriba
2013-03-24 20:20:29 +00:00
parent 5430d82f9f
commit ec4d3bc41e
5 changed files with 221 additions and 230 deletions

View File

@ -38,6 +38,7 @@
<tr> <tr>
<td width="100%" bgcolor="#E8F5FF"> <td width="100%" bgcolor="#E8F5FF">
<a href="#Introduction">Introduction</a><br> <a href="#Introduction">Introduction</a><br>
<a href="#C++11">C++11</a><br>
<a href="#Macros">Macros</a><br> <a href="#Macros">Macros</a><br>
<a href="#Deprecated-names">Deprecated names</a><br> <a href="#Deprecated-names">Deprecated names</a><br>
<a href="#Breaking-changes">Breaking changes</a><br> <a href="#Breaking-changes">Breaking changes</a><br>
@ -70,11 +71,15 @@
<h2><a name="Introduction">Introduction</a></h2> <h2><a name="Introduction">Introduction</a></h2>
<p>This reference documentation describes components that&nbsp; <p>This reference documentation describes components that&nbsp;programs may use to report error conditions originating from the operating
programs may use to report error conditions originating from the operating
system or other low-level application program interfaces.</p> system or other low-level application program interfaces.</p>
<p>Boost.System library components never change the value of <code> <p>Boost.System library components never change the value of <code>
errno</code>.</p> errno</code>.</p>
<h2><a name="C++11">C++11</a></h2>
<p>The library is documented to use several C++11 features, including <code>
noexcept</code> and explicit conversion operators. The actual implementation
uses C++11 features only when they are available, and otherwise falls back on
C++03 features.</p>
<h2><a name="Macros">Macros</a></h2> <h2><a name="Macros">Macros</a></h2>
<p>Users may defined the following macros if desired. Sensible defaults are <p>Users may defined the following macros if desired. Sensible defaults are
provided, so users may ignore these macros if they prefer.</p> provided, so users may ignore these macros if they prefer.</p>
@ -178,6 +183,9 @@ fixed by globally adding () to these names to turn them into function calls.</p>
namespace system namespace system
{ {
class <a href="#Class-error_category">error_category</a>; class <a href="#Class-error_category">error_category</a>;
const error_category &amp; <a href="#system_category">system_category</a>() noexcept;
const error_category &amp; <a href="#generic_category">generic_category</a>() noexcept;
class <a href="#Class-error_code">error_code</a>; class <a href="#Class-error_code">error_code</a>;
class <a href="#Class-error_condition">error_condition</a>; class <a href="#Class-error_condition">error_condition</a>;
@ -281,21 +289,21 @@ fixed by globally adding () to these names to turn them into function calls.</p>
// <a href="#Non-member-functions">non-member functions</a> // <a href="#Non-member-functions">non-member functions</a>
bool operator==( const error_code &amp; lhs, const error_code &amp; rhs ); bool operator==( const error_code &amp; lhs, const error_code &amp; rhs ) noexcept;
bool operator==( const error_code &amp; code, const error_condition &amp; condition ); bool operator==( const error_code &amp; code, const error_condition &amp; condition ) noexcept;
bool operator==( const error_condition &amp; condition, const error_code &amp; code ); bool operator==( const error_condition &amp; condition, const error_code &amp; code ) noexcept;
bool operator==( const error_condition &amp; lhs, const error_condition &amp; rhs ); bool operator==( const error_condition &amp; lhs, const error_condition &amp; rhs ) noexcept;
bool operator!=( const error_code &amp; lhs, const error_code &amp; rhs ); bool operator!=( const error_code &amp; lhs, const error_code &amp; rhs ) noexcept;
bool operator!=( const error_code &amp; code, const error_condition &amp; condition ); bool operator!=( const error_code &amp; code, const error_condition &amp; condition ) noexcept;
bool operator!=( const error_condition &amp; condition, const error_code &amp; code ); bool operator!=( const error_condition &amp; condition, const error_code &amp; code ) noexcept;
bool operator!=( const error_condition &amp; lhs, const error_condition &amp; rhs ); bool operator!=( const error_condition &amp; lhs, const error_condition &amp; rhs ) noexcept;
bool operator&lt;( const error_code &amp; lhs, const error_code &amp; rhs ); bool operator&lt;( const error_code &amp; lhs, const error_code &amp; rhs ) noexcept;
bool operator&lt;( const error_condition &amp; lhs, const error_condition &amp; rhs ); bool operator&lt;( const error_condition &amp; lhs, const error_condition &amp; rhs ) noexcept;
error_code make_error_code( errc::errc_t e ); error_code make_error_code( errc::errc_t e ) noexcept;
error_condition make_error_condition( errc::errc_t e ); error_condition make_error_condition( errc::errc_t e ) noexcept;
template &lt;class charT, class traits&gt; template &lt;class charT, class traits&gt;
std::basic_ostream&lt;charT,traits&gt;&amp; std::basic_ostream&lt;charT,traits&gt;&amp;
@ -312,6 +320,17 @@ is_error_condition_enum</code> templates to indicate that a type is eligible for
class <code>error_code</code> and <code>error_condition</code> automatic class <code>error_code</code> and <code>error_condition</code> automatic
conversions respectively.</p> conversions respectively.</p>
<pre>const error_category &amp; <a name="system_category">system_category</a>();</pre>
<blockquote>
<p><i>Returns:</i> A reference to a <code>error_category</code> object
identifying errors originating from the operating system.</p>
</blockquote>
<pre>const error_category &amp; <a name="generic_category">generic_category</a>();</pre>
<blockquote>
<p><i>Returns:</i> A reference to a <code>error_category</code> object
identifying portable error conditions.</p>
</blockquote>
<h2><a name="Class-error_category">Class <code>error_category</code></a></h2> <h2><a name="Class-error_category">Class <code>error_category</code></a></h2>
<p>The class <code>error_category</code> defines the base class for types used <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> to identify the source and encoding of a particular category of error code.</p>
@ -336,37 +355,33 @@ types should create a single object of each such type. <i>
public: public:
virtual ~error_category(); virtual ~error_category();
virtual const char * name() const = 0; virtual const char * name() const noexcept = 0;
virtual string message( int ev ) const = 0; virtual string message( int ev ) const = 0;
virtual error_condition default_error_condition( int ev ) const; virtual error_condition default_error_condition( int ev ) const noexcept;
virtual bool equivalent( int code, const error_condition &amp; condition ) const; virtual bool equivalent( int code, const error_condition &amp; condition )
virtual bool equivalent( const error_code &amp; code, int condition ) const; const noexcept;
virtual bool equivalent( const error_code &amp; code, int condition ) const noexcept;
bool operator==( const error_category &amp; rhs ) const; bool operator==( const error_category &amp; rhs ) const noexcept;
bool operator!=( const error_category &amp; rhs ) const; bool operator!=( const error_category &amp; rhs ) const noexcept;
bool operator&lt; ( const error_category &amp; rhs ) const; bool operator&lt; ( const error_category &amp; rhs ) const noexcept;
}; };
const error_category &amp; system_category();
const error_category &amp; generic_category();
} }
}</pre> }</pre>
</blockquote> </blockquote>
<h3><a name="Class-error_category-virtual-members">Class <code>error_category</code> virtual members</a></h3> <h3><a name="Class-error_category-virtual-members">Class <code>error_category</code> virtual members</a></h3>
<p>Classes derived from <code>error_category</code> shall behave as specified in <p>Classes derived from <code>error_category</code> shall behave as specified in
this subclause.</p> this subclause.</p>
<pre>virtual const char * name() const=0;</pre> <pre>virtual const char * name() const noexcept =0;</pre>
<blockquote> <blockquote>
<p><i>Returns: </i>a string naming the error category.</p> <p><i>Returns: </i>a string naming the error category.</p>
<p><i>Throws:</i> Nothing.</p>
</blockquote> </blockquote>
<pre>virtual string message( int ev ) const=0;</pre> <pre>virtual string message( int ev ) const noexcept =0;</pre>
<blockquote> <blockquote>
<p><i>Returns:</i> A string that describes the error denoted by <p><i>Returns:</i> A string that describes the error denoted by
<code>ev</code>.</p> <code>ev</code>.</p>
<p><i>Throws:</i> Nothing.</p>
</blockquote> </blockquote>
<p><code>virtual error_condition default_error_condition( int ev ) const;</code></p> <pre>virtual error_condition default_error_condition( int ev ) const noexcept;</pre>
<blockquote> <blockquote>
<p><i>Returns:</i>&nbsp; <code>error_condition( ev, *this )</code>.</p> <p><i>Returns:</i>&nbsp; <code>error_condition( ev, *this )</code>.</p>
<blockquote> <blockquote>
@ -375,52 +390,33 @@ this subclause.</p>
and return it as an <code>error_condition</code> for that category. <i>--end and return it as an <code>error_condition</code> for that category. <i>--end
note</i>]</p> note</i>]</p>
</blockquote> </blockquote>
<p><i>Throws:</i> Nothing.</p> </blockquote>
</blockquote> <pre>virtual bool equivalent( int code, const error_condition &amp; condition ) const noexcept;</pre>
<p><code>virtual bool equivalent( int code, const error_condition &amp;
condition )
const;</code></p>
<blockquote> <blockquote>
<p><i>Returns:</i> <code>default_error_condition( code ) == condition</code>.</p> <p><i>Returns:</i> <code>default_error_condition( code ) == condition</code>.</p>
<p><i>Throws:</i> Nothing.</p> </blockquote>
</blockquote> <pre>virtual bool equivalent( const error_code &amp; code, int condition ) const noexcept;</pre>
<p><code>virtual bool equivalent( const error_code &amp; code, int condition ) const;</code></p>
<blockquote> <blockquote>
<p><i>Returns:</i> <code>*this == code.category() &amp;&amp; code.value() == condition</code>.</p> <p><i>Returns:</i> <code>*this == code.category() &amp;&amp; code.value() == condition</code>.</p>
<p><i>Throws:</i> Nothing.</p> </blockquote>
</blockquote>
<h3><a name="Class-error_category-non-virtual-members">Class <code>error_category</code> non-virtual members</a></h3> <h3><a name="Class-error_category-non-virtual-members">Class <code>error_category</code> non-virtual members</a></h3>
<p><code>bool operator==( const error_category &amp; rhs ) const;</code></p> <pre>bool operator==( const error_category &amp; rhs ) const noexcept;</pre>
<blockquote> <blockquote>
<p><i>Returns:</i> <code>this == &amp;rhs</code>.</p> <p><i>Returns:</i> <code>this == &amp;rhs</code>.</p>
</blockquote> </blockquote>
<p><code>bool operator!=( const error_category &amp; rhs ) const;</code></p> <pre>bool operator!=( const error_category &amp; rhs ) const noexcept;</pre>
<blockquote> <blockquote>
<p><i>Returns:</i> <code>this != &amp;rhs</code>.</p> <p><i>Returns:</i> <code>this != &amp;rhs</code>.</p>
</blockquote> </blockquote>
<pre>bool operator&lt;( const error_category &amp; rhs ) const;</pre> <pre>bool operator&lt;( const error_category &amp; rhs ) const noexcept;</pre>
<blockquote> <blockquote>
<p><i>Returns:</i> <code>std::less&lt;const error_category*&gt;()( this, &amp;rhs )</code>.</p> <p><i>Returns:</i> <code>std::less&lt;const error_category*&gt;()( this, &amp;rhs&nbsp;
noexcept)</code>.</p>
<blockquote> <blockquote>
<p><i>[Note:</i> <code>std::less</code> provides a total ordering for <p><i>[Note:</i> <code>std::less</code> provides a total ordering for
pointers. <i>--end note]</i></p> pointers. <i>--end note]</i></p>
</blockquote> </blockquote>
<p><i>Throws:</i> Nothing.</p>
</blockquote>
<h3><a name="Class-error_category-non-member-functions">Class <code>error_category</code>
non-member functions</a></h3>
<pre>const error_category &amp; system_category();</pre>
<blockquote>
<p><i>Returns:</i> A reference to a <code>error_category</code> object
identifying errors originating from the operating system.</p>
<p><i>Throws:</i> Nothing.</p>
</blockquote>
<pre>const error_category &amp; generic_category();</pre>
<blockquote>
<p><i>Returns:</i> A reference to a <code>error_category</code> object
identifying portable error conditions.</p>
<p><i>Throws:</i> Nothing.</p>
</blockquote> </blockquote>
<h2><a name="Class-error_code">Class <code> <h2><a name="Class-error_code">Class <code>
error_code</code></a></h2> error_code</code></a></h2>
@ -440,21 +436,21 @@ error_code</code> synopsis</a></h3>
public: public:
// constructors: // constructors:
error_code(); error_code() noexcept;
error_code( val, const error_category &amp; cat ); error_code( val, const error_category &amp; cat ) noexcept;
template &lt;class <code>ErrorCodeEnum</code>&gt; template &lt;class <code>ErrorCodeEnum</code>&gt;
error_code(<code> ErrorCodeEnum</code> e ); error_code(<code> ErrorCodeEnum</code> e ) noexcept;
// modifiers: // modifiers:
void assign( int val, const error_category &amp; cat ); void assign( int val, const error_category &amp; cat ) noexcept;
template&lt;typename <code>ErrorCodeEnum</code>&gt; template&lt;typename <code>ErrorCodeEnum</code>&gt;
error_code &amp; operator=( <code>ErrorCodeEnum</code> val );; error_code &amp; operator=( <code>ErrorCodeEnum</code> val ) noexcept;
void clear(); void clear() noexcept;
// observers: // observers:
int value() const; int value() const noexcept;
cont error_category &amp; category() const; cont error_category &amp; category() const noexcept;
error_condition default_error_condition() const; error_condition default_error_condition() const noexcept;
string message() const; string message() const;
operator unspecified-bool-type() const; operator unspecified-bool-type() const;
@ -467,71 +463,63 @@ error_code</code> synopsis</a></h3>
</blockquote> </blockquote>
<h3><a name="Class-error_code-constructors">Class <code> <h3><a name="Class-error_code-constructors">Class <code>
error_code</code> constructors</a></h3> error_code</code> constructors</a></h3>
<pre>error_code();</pre> <pre>error_code() noexcept;</pre>
<blockquote> <blockquote>
<p><i>Effects: </i>Constructs an object of type <code>error_code</code>.</p> <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;system_category()</code>.</p> <p><i>Postconditions:</i> <code>val_ == 0 &amp;&amp; cat_ == &amp;system_category()</code>.</p>
<p><i>Throws:</i> Nothing.</p>
</blockquote> </blockquote>
<pre>error_code( int val, const error_category &amp; cat );</pre> <pre>error_code( int val, const error_category &amp; cat ) noexcept;</pre>
<blockquote> <blockquote>
<p><i>Effects: </i>Constructs an object of type <code>error_code</code>.</p> <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>Postconditions:</i> <code>val_ == val &amp;&amp; cat_ == &amp;cat</code>.</p>
<p><i>Throws:</i> Nothing.</p>
</blockquote> </blockquote>
<pre>template &lt;class <code>ErrorCodeEnum</code>&gt; <pre>template &lt;class <code>ErrorCodeEnum</code>&gt;
error_code(<code> ErrorCodeEnum</code> val );</pre> error_code(<code> ErrorCodeEnum</code> val ) noexcept;</pre>
<blockquote> <blockquote>
<p><i>Effects: </i>Constructs an object of type <code>error_code</code>.</p> <p><i>Effects: </i>Constructs an object of type <code>error_code</code>.</p>
<p><i>Postconditions:</i> <code>*this == make_error_code( val )</code>.</p> <p><i>Postconditions:</i> <code>*this == make_error_code( val )</code>.</p>
<p><i>Throws:</i> Nothing.</p>
<p><i>Remarks:</i> This constructor shall not participate in overload <p><i>Remarks:</i> This constructor shall not participate in overload
resolution unless <code>is_error_code_enum&lt;ErrorCodeEnum&gt;::value</code> is resolution unless <code>is_error_code_enum&lt;ErrorCodeEnum&gt;::value</code> is
<code>true</code>.</p> <code>true</code>.</p>
</blockquote> </blockquote>
<h3><a name="Class-error_code-modifiers">Class <code> <h3><a name="Class-error_code-modifiers">Class <code>
error_code</code> modifiers</a></h3> error_code</code> modifiers</a></h3>
<pre>void assign( int val, const error_category &amp; cat );</pre> <pre>void assign( int val, const error_category &amp; cat ) noexcept;</pre>
<blockquote> <blockquote>
<p><i>Postconditions:</i> <code>val_ == val &amp;&amp; cat_ == &amp;cat</code>.</p> <p><i>Postconditions:</i> <code>val_ == val &amp;&amp; cat_ == &amp;cat</code>.</p>
<p><i>Throws:</i> Nothing.</p>
</blockquote> </blockquote>
<pre>template&lt;typename <code>ErrorCodeEnum</code>&gt; <pre>template&lt;typename <code>ErrorCodeEnum</code>&gt;
error_code &amp; operator=( <code>ErrorCodeEnum</code> val );</pre> error_code &amp; operator=( <code>ErrorCodeEnum</code> val ) noexcept;</pre>
<blockquote> <blockquote>
<p><i>Postconditions:</i> <code>*this == make_error_code( val )</code>.</p> <p><i>Postconditions:</i> <code>*this == make_error_code( val )</code>.</p>
<p><i>Throws:</i> Nothing.</p>
<p><i>Remarks:</i> This operator shall not participate in overload resolution <p><i>Remarks:</i> This operator shall not participate in overload resolution
unless <code>is_error_code_enum&lt;ErrorCodeEnum&gt;::value</code> is <code>true</code>.</p> unless <code>is_error_code_enum&lt;ErrorCodeEnum&gt;::value</code> is <code>true</code>.</p>
</blockquote> </blockquote>
<p><code>void clear();</code></p> <pre><code>void clear() noexcept;</code></pre>
<blockquote> <blockquote>
<p><i>postcondition:</i> <code>value() == 0 &amp;&amp; category() == <p><i>postcondition:</i> <code>value() == 0 &amp;&amp; category() ==
system_category()</code></p> system_category()</code></p>
</blockquote> </blockquote>
<h3><a name="Class-error_code-observers">Class <code> <h3><a name="Class-error_code-observers">Class <code>
error_code</code> observers</a></h3> error_code</code> observers</a></h3>
<p><code>int value() const;</code></p> <pre><code>int value() const noexcept;</code></pre>
<blockquote> <blockquote>
<p><i>Returns:</i> <code>val_</code>.</p> <p><i>Returns:</i> <code>val_</code>.</p>
<p><i>Throws:</i> Nothing.</p> </blockquote>
</blockquote> <pre><code>const error_category &amp; category() const noexcept;</code></pre>
<p><code>const error_category &amp; category() const;</code></p>
<blockquote> <blockquote>
<p><i>Returns:</i> <code>*cat_</code>.</p> <p><i>Returns:</i> <code>*cat_</code>.</p>
<p><i>Throws:</i> Nothing.</p> </blockquote>
</blockquote> <pre>error_condition default_error_condition() const noexcept;</pre>
<pre>error_condition default_error_condition() const;</pre>
<blockquote> <blockquote>
<p><i>Returns:</i>&nbsp; <code>category().default_error_condition( value())</code>.</p> <p><i>Returns:</i>&nbsp; <code>category().default_error_condition( value())</code>.</p>
<p><i>Throws:</i> Nothing.</p>
</blockquote> </blockquote>
<p><code>string message() const;</code></p> <pre><code>string message() const;</code></pre>
<blockquote> <blockquote>
<p><i>Returns:</i>&nbsp; <code>category().message( value())</code>.</p> <p><i>Returns:</i>&nbsp; <code>category().message( value())</code>.</p>
<p><i>Throws:</i> Nothing.</p> <p><i>Throws:</i> Nothing.</p>
</blockquote> </blockquote>
<p><code>operator <i>unspecified-bool-type</i>() const;</code></p> <pre>operator unspecified-bool-type() const;</pre>
<blockquote> <blockquote>
<p><i>Returns:</i> if <code>value() != 0</code>, returns a value that will evaluate <p><i>Returns:</i> if <code>value() != 0</code>, returns a value that will evaluate
<code>true</code> in a boolean context; otherwise, returns a value that will <code>true</code> in a boolean context; otherwise, returns a value that will
@ -560,22 +548,22 @@ implementation specific. <i>--end note ]</i></p>
public: public:
// constructors: // constructors:
error_condition(); error_condition() noexcept;
error_condition( int val, const error_category &amp; cat ); error_condition( int val, const error_category &amp; cat ) noexcept;
template &lt;class ErrorConditionEnum&gt; template &lt;class ErrorConditionEnum&gt;
error_condition( errorConditionEnum val ); error_condition( errorConditionEnum val ) noexcept;
// modifiers: // modifiers:
void assign( int val, const error_category &amp; cat ); void assign( int val, const error_category &amp; cat ) noexcept;
template&lt;typename ErrorConditionEnum&gt; template&lt;typename ErrorConditionEnum&gt;
error_condition &amp; operator=( ErrorConditionEnum val ); error_condition &amp; operator=( ErrorConditionEnum val ) noexcept;
void clear(); void clear() noexcept;
// observers: // observers:
int value() const; int value() const noexcept;
const error_category &amp; category() const; const error_category &amp; category() const noexcept;
string message() const; string message() const;
operator unspecified-bool-type () const; operator unspecified-bool-type () const noexcept;
private: private:
int val_; // <i>exposition only</i> int val_; // <i>exposition only</i>
@ -586,65 +574,57 @@ implementation specific. <i>--end note ]</i></p>
</blockquote> </blockquote>
<h3><a name="Class-error_condition-constructors">Class <code>error_condition</code> <h3><a name="Class-error_condition-constructors">Class <code>error_condition</code>
constructors</a></h3> constructors</a></h3>
<pre>error_condition(); </pre> <pre>error_condition() noexcept; </pre>
<blockquote> <blockquote>
<p><i>Effects:</i> Constructs an object of type <code>error_condition</code>.</p> <p><i>Effects:</i> Constructs an object of type <code>error_condition</code>.</p>
<p><i>Postconditions:</i> <code>val_ == 0 and cat_ == &amp;generic_category()</code>.</p> <p><i>Postconditions:</i> <code>val_ == 0 and cat_ == &amp;generic_category()</code>.</p>
<p><i>Throws:</i> Nothing.</p>
</blockquote> </blockquote>
<pre>error_condition( int val, const error_category &amp; cat );</pre> <pre>error_condition( int val, const error_category &amp; cat ) noexcept;</pre>
<blockquote> <blockquote>
<p><i>Effects: </i>Constructs an object of type error_condition.</p> <p><i>Effects: </i>Constructs an object of type error_condition.</p>
<p><i>Postconditions:</i> <code>val_ == val and cat_ == &amp;cat</code>.</p> <p><i>Postconditions:</i> <code>val_ == val and cat_ == &amp;cat</code>.</p>
<p><i>Throws:</i> Nothing.</p>
</blockquote> </blockquote>
<pre>template &lt;class ErrorConditionEnum&gt; <pre>template &lt;class ErrorConditionEnum&gt;
error_condition( ErrorConditionEnum e );</pre> error_condition( ErrorConditionEnum e ) noexcept;</pre>
<blockquote> <blockquote>
<p><i>Effects:</i> Constructs an object of type <code>error_condition</code>.</p> <p><i>Effects:</i> Constructs an object of type <code>error_condition</code>.</p>
<p><i>Postconditions:</i> <code>*this == make_error_condition(e)</code>.</p> <p><i>Postconditions:</i> <code>*this == make_error_condition(e)</code>.</p>
<p><i>Throws:</i> Nothing.</p>
<p><i>Remarks:</i> This constructor shall not participate in overload <p><i>Remarks:</i> This constructor shall not participate in overload
resolution unless <code>is_error_condition_enum&lt;ErrorConditionEnum&gt;::value</code> resolution unless <code>is_error_condition_enum&lt;ErrorConditionEnum&gt;::value</code>
is <code>true</code>.</p> is <code>true</code>.</p>
</blockquote> </blockquote>
<h3><a name="Class-error_condition-modifiers">Class <code>error_condition</code> <h3><a name="Class-error_condition-modifiers">Class <code>error_condition</code>
modifiers</a></h3> modifiers</a></h3>
<pre>void assign( int val, const error_category &amp; cat ); </pre> <pre>void assign( int val, const error_category &amp; cat ) noexcept; </pre>
<blockquote> <blockquote>
<p><i>Postconditions:</i> <code>val_ == val and cat_ == &amp;cat</code>. </p> <p><i>Postconditions:</i> <code>val_ == val and cat_ == &amp;cat</code>. </p>
<p><i>Throws:</i> Nothing.</p>
</blockquote> </blockquote>
<pre>template&lt;typename ErrorConditionEnum&gt; <pre>template&lt;typename ErrorConditionEnum&gt;
error_condition &amp; operator=( ErrorConditionEnum e );</pre> error_condition &amp; operator=( ErrorConditionEnum e ) noexcept;</pre>
<blockquote> <blockquote>
<p><i>Postconditions:</i> <code>*this == make_error_condition( e )</code>.</p> <p><i>Postconditions:</i> <code>*this == make_error_condition( e )</code>.</p>
<p><i>Returns:</i> <code>*this</code>.</p> <p><i>Returns:</i> <code>*this</code>.</p>
<p><i>Throws:</i> Nothing.</p>
<p><i>Remarks:</i> This operator shall not participate in overload resolution <p><i>Remarks:</i> This operator shall not participate in overload resolution
unless <code>is_error_condition_enum&lt;ErrorConditionEnum&gt;::value</code> is unless <code>is_error_condition_enum&lt;ErrorConditionEnum&gt;::value</code> is
<code>true</code>.</p> <code>true</code>.</p>
</blockquote> </blockquote>
<p><code>void clear();</code></p> <pre>void clear() noexcept;</pre>
<blockquote> <blockquote>
<p><i>postcondition:</i> <code>value() == 0 &amp;&amp; category() == generic_category()</code></p> <p><i>Postcondition:</i> <code>value() == 0 &amp;&amp; category() == generic_category()</code></p>
</blockquote> </blockquote>
<h3><a name="Class-error_condition-observers">Class <code>error_condition</code> <h3><a name="Class-error_condition-observers">Class <code>error_condition</code>
observers</a></h3> observers</a></h3>
<pre>int value() const;</pre> <pre>int value() const noexcept;</pre>
<blockquote> <blockquote>
<p><i>Returns:</i> <code>val_</code>.</p> <p><i>Returns:</i> <code>val_</code>.</p>
<p><i>Throws:</i> Nothing</p>
</blockquote> </blockquote>
<pre>const error_category &amp; category() const;</pre> <pre>const error_category &amp; category() const noexcept;</pre>
<blockquote> <blockquote>
<p><i>Returns:</i> <code>*cat_</code>.</p> <p><i>Returns:</i> <code>*cat_</code>.</p>
<p>Throws: Nothing.</p>
</blockquote> </blockquote>
<pre>string message() const;</pre> <pre>string message() const;</pre>
<blockquote> <blockquote>
<p><i>Returns:</i> <code>category().message( value() )</code>.</p> <p><i>Returns:</i> <code>category().message( value() )</code>.</p>
<p><i>Throws:</i> Nothing.</p>
</blockquote> </blockquote>
<pre>operator unspecified-bool-type () const;</pre> <pre>operator unspecified-bool-type () const;</pre>
<blockquote> <blockquote>
@ -690,58 +670,50 @@ semantics:</p>
</blockquote> </blockquote>
</blockquote> </blockquote>
<h2><a name="Non-member-functions">Non-member functions</a></h2> <h2><a name="Non-member-functions">Non-member functions</a></h2>
<pre>bool operator==( const error_code &amp; lhs, const error_code &amp; rhs );</pre> <pre>bool operator==( const error_code &amp; lhs, const error_code &amp; rhs ) noexcept;</pre>
<blockquote> <blockquote>
<p><i>Returns:</i> <code>lhs.category() == rhs.category() &amp;&amp; lhs.value() == <p><i>Returns:</i> <code>lhs.category() == rhs.category() &amp;&amp; lhs.value() ==
rhs.value()</code>.</p> rhs.value()</code>.</p>
<p><i>Throws: </i>Nothing.</p>
</blockquote> </blockquote>
<pre>bool operator==( const error_code &amp; code, const error_condition &amp; condition ); <pre>bool operator==( const error_code &amp; code, const error_condition &amp; condition ) noexcept;
bool operator==( const error_condition &amp; condition, const error_code &amp; code );</pre> bool operator==( const error_condition &amp; condition, const error_code &amp; code ) noexcept;</pre>
<blockquote> <blockquote>
<p><i>Returns:</i> <code>code.category().equivalent( code.value(), condition )<br> <p><i>Returns:</i> <code>code.category().equivalent( code.value(), condition )<br>
|| condition.category().equivalent( code, condition.value() )</code>.</p> || condition.category().equivalent( code, condition.value() )</code>.</p>
<p><i>Throws: </i>Nothing.</p>
</blockquote> </blockquote>
<pre>bool operator==( const error_condition &amp; lhs, const error_condition &amp; rhs );</pre> <pre>bool operator==( const error_condition &amp; lhs, const error_condition &amp; rhs ) noexcept;</pre>
<blockquote> <blockquote>
<p><i>Returns:</i> <code>lhs.category() == rhs.category() &amp;&amp; lhs.value() == <p><i>Returns:</i> <code>lhs.category() == rhs.category() &amp;&amp; lhs.value() ==
rhs.value()</code>.</p> rhs.value()</code>.</p>
<p><i>Throws: </i>Nothing.</p>
</blockquote> </blockquote>
<pre>bool operator!=( const error_code &amp; lhs, const error_code &amp; rhs );</pre> <pre>bool operator!=( const error_code &amp; lhs, const error_code &amp; rhs ) noexcept;</pre>
<blockquote> <blockquote>
<p><i>Returns:</i> <code>!(lhs == rhs )</code>.</p> <p><i>Returns:</i> <code>!(lhs == rhs )</code>.</p>
<p><i>Throws: </i>Nothing.</p>
</blockquote> </blockquote>
<pre>bool operator!=( const error_code &amp; code, const error_condition &amp; condition ); <pre>bool operator!=( const error_code &amp; code, const error_condition &amp; condition ) noexcept;
bool operator!=( const error_condition &amp; condition, const error_code &amp; code );</pre> bool operator!=( const error_condition &amp; condition, const error_code &amp; code ) noexcept;</pre>
<blockquote> <blockquote>
<p><i>Returns:</i><code> !( code ==&nbsp; condition )</code>.</p> <p><i>Returns:</i><code> !( code ==&nbsp; condition )</code>.</p>
<p><i>Throws: </i>Nothing.</p>
</blockquote> </blockquote>
<pre>bool operator!=( const error_condition &amp; lhs, const error_condition &amp; rhs );</pre> <pre>bool operator!=( const error_condition &amp; lhs, const error_condition &amp; rhs ) noexcept;</pre>
<blockquote> <blockquote>
<p><i>Returns:</i> <code>!(lhs == rhs )</code>.</p> <p><i>Returns:</i> <code>!(lhs == rhs )</code>.</p>
<p><i>Throws: </i>Nothing.</p>
</blockquote> </blockquote>
<pre>bool operator&lt;( const error_code &amp; lhs, const error_code &amp; rhs );</pre> <pre>bool operator&lt;( const error_code &amp; lhs, const error_code &amp; rhs ) noexcept;</pre>
<blockquote> <blockquote>
<p><i>Returns:</i> <code>lhs.category() &lt; rhs.category()<br> <p><i>Returns:</i> <code>lhs.category() &lt; rhs.category()<br>
&nbsp; || (lhs.category() == rhs.category() &amp;&amp; lhs.value() &lt; rhs.value())</code>.</p> &nbsp; || (lhs.category() == rhs.category() &amp;&amp; lhs.value() &lt; rhs.value())</code>.</p>
<p><i>Throws: </i>Nothing.</p>
</blockquote> </blockquote>
<pre>bool operator&lt;( const error_condition &amp; lhs, const error_condition &amp; rhs );</pre> <pre>bool operator&lt;( const error_condition &amp; lhs, const error_condition &amp; rhs ) noexcept;</pre>
<blockquote> <blockquote>
<p><i>Returns:</i> <code>lhs.category() &lt; rhs.category()<br> <p><i>Returns:</i> <code>lhs.category() &lt; rhs.category()<br>
&nbsp; || (lhs.category() == rhs.category() &amp;&amp; lhs.value() &lt; rhs.value())</code>.</p> &nbsp; || (lhs.category() == rhs.category() &amp;&amp; lhs.value() &lt; rhs.value())</code>.</p>
<p><i>Throws: </i>Nothing.</p>
</blockquote> </blockquote>
<pre>error_code make_error_code( errc::errc_t e );</pre> <pre>error_code make_error_code( errc::errc_t e ) noexcept;</pre>
<blockquote> <blockquote>
<p><i>Returns:</i> <code>error_code( e, generic_category())</code>.</p> <p><i>Returns:</i> <code>error_code( e, generic_category())</code>.</p>
</blockquote> </blockquote>
<pre>error_condition make_error_condition( errc::errc_t e );</pre> <pre>error_condition make_error_condition( errc::errc_t e ) noexcept;</pre>
<blockquote> <blockquote>
<p><i>Returns:</i> <code>error_condition( static_cast&lt;int&gt;( e ), generic_category())</code>.</p> <p><i>Returns:</i> <code>error_condition( static_cast&lt;int&gt;( e ), generic_category())</code>.</p>
</blockquote> </blockquote>
@ -840,10 +812,10 @@ application program interfaces.</p>
<hr> <hr>
<p>Revised <p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%B %d, %Y" startspan -->June 29, 2010<!--webbot bot="Timestamp" endspan i-checksum="14432" --> </font> <!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%B %d, %Y" startspan -->February 27, 2013<!--webbot bot="Timestamp" endspan i-checksum="41547" --> </font>
</p> </p>
<p><EFBFBD> Copyright Beman Dawes, 2006, 2007, 2008</p> <p><EFBFBD> Copyright Beman Dawes, 2006, 2007, 2008, 2013</p>
<p>Distributed under the Boost Software License, Version 1.0. See <p>Distributed under the Boost Software License, Version 1.0. See
<a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a></p> <a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a></p>

View File

@ -23,7 +23,7 @@
#include <functional> #include <functional>
// TODO: undef these macros if not already defined // TODO: undef these macros if not already defined
#include <boost/cerrno.hpp> #include <boost/cerrno.hpp>
#if !defined(BOOST_POSIX_API) && !defined(BOOST_WINDOWS_API) #if !defined(BOOST_POSIX_API) && !defined(BOOST_WINDOWS_API)
# error BOOST_POSIX_API or BOOST_WINDOWS_API must be defined # error BOOST_POSIX_API or BOOST_WINDOWS_API must be defined
@ -31,6 +31,10 @@
#include <boost/config/abi_prefix.hpp> // must be the last #include #include <boost/config/abi_prefix.hpp> // must be the last #include
#ifndef BOOST_SYSTEM_NOEXCEPT
#define BOOST_SYSTEM_NOEXCEPT BOOST_NOEXCEPT
#endif
namespace boost namespace boost
{ {
namespace system namespace system
@ -184,17 +188,17 @@ namespace boost
public: public:
virtual ~error_category(){} virtual ~error_category(){}
virtual const char * name() const = 0; virtual const char * name() const BOOST_SYSTEM_NOEXCEPT = 0;
virtual std::string message( int ev ) const = 0; virtual std::string message( int ev ) const = 0;
virtual error_condition default_error_condition( int ev ) const; inline virtual error_condition default_error_condition( int ev ) const BOOST_SYSTEM_NOEXCEPT;
virtual bool equivalent( int code, inline virtual bool equivalent( int code,
const error_condition & condition ) const; const error_condition & condition ) const BOOST_SYSTEM_NOEXCEPT;
virtual bool equivalent( const error_code & code, inline virtual bool equivalent( const error_code & code,
int condition ) const; int condition ) const BOOST_SYSTEM_NOEXCEPT;
bool operator==(const error_category & rhs) const { return this == &rhs; } bool operator==(const error_category & rhs) const BOOST_SYSTEM_NOEXCEPT { return this == &rhs; }
bool operator!=(const error_category & rhs) const { return this != &rhs; } bool operator!=(const error_category & rhs) const BOOST_SYSTEM_NOEXCEPT { return this != &rhs; }
bool operator<( const error_category & rhs ) const bool operator<( const error_category & rhs ) const BOOST_SYSTEM_NOEXCEPT
{ {
return std::less<const error_category*>()( this, &rhs ); return std::less<const error_category*>()( this, &rhs );
} }
@ -202,9 +206,13 @@ namespace boost
// predefined error categories -----------------------------------------// // predefined error categories -----------------------------------------//
BOOST_SYSTEM_DECL const error_category & system_category(); # ifdef BOOST_ERROR_CODE_HEADER_ONLY
BOOST_SYSTEM_DECL const error_category & generic_category(); inline const error_category & system_category() BOOST_SYSTEM_NOEXCEPT;
inline const error_category & generic_category() BOOST_SYSTEM_NOEXCEPT;
#else
BOOST_SYSTEM_DECL const error_category & system_category() BOOST_SYSTEM_NOEXCEPT;
BOOST_SYSTEM_DECL const error_category & generic_category() BOOST_SYSTEM_NOEXCEPT;
#endif
// deprecated synonyms --------------------------------------------------// // deprecated synonyms --------------------------------------------------//
# ifndef BOOST_SYSTEM_NO_DEPRECATED # ifndef BOOST_SYSTEM_NO_DEPRECATED
@ -225,52 +233,52 @@ namespace boost
public: public:
// constructors: // constructors:
error_condition() : m_val(0), m_cat(&generic_category()) {} error_condition() BOOST_SYSTEM_NOEXCEPT : m_val(0), m_cat(&generic_category()) {}
error_condition( int val, const error_category & cat ) : m_val(val), m_cat(&cat) {} error_condition( int val, const error_category & cat ) BOOST_SYSTEM_NOEXCEPT : m_val(val), m_cat(&cat) {}
template <class ErrorConditionEnum> template <class ErrorConditionEnum>
error_condition(ErrorConditionEnum e, error_condition(ErrorConditionEnum e,
typename boost::enable_if<is_error_condition_enum<ErrorConditionEnum> >::type* = 0) typename boost::enable_if<is_error_condition_enum<ErrorConditionEnum> >::type* = 0) BOOST_SYSTEM_NOEXCEPT
{ {
*this = make_error_condition(e); *this = make_error_condition(e);
} }
// modifiers: // modifiers:
void assign( int val, const error_category & cat ) void assign( int val, const error_category & cat ) BOOST_SYSTEM_NOEXCEPT
{ {
m_val = val; m_val = val;
m_cat = &cat; m_cat = &cat;
} }
template<typename ErrorConditionEnum> template<typename ErrorConditionEnum>
typename boost::enable_if<is_error_condition_enum<ErrorConditionEnum>, error_condition>::type & typename boost::enable_if<is_error_condition_enum<ErrorConditionEnum>, error_condition>::type &
operator=( ErrorConditionEnum val ) operator=( ErrorConditionEnum val ) BOOST_SYSTEM_NOEXCEPT
{ {
*this = make_error_condition(val); *this = make_error_condition(val);
return *this; return *this;
} }
void clear() void clear() BOOST_SYSTEM_NOEXCEPT
{ {
m_val = 0; m_val = 0;
m_cat = &generic_category(); m_cat = &generic_category();
} }
// observers: // observers:
int value() const { return m_val; } int value() const BOOST_SYSTEM_NOEXCEPT { return m_val; }
const error_category & category() const { return *m_cat; } const error_category & category() const BOOST_SYSTEM_NOEXCEPT { return *m_cat; }
std::string message() const { return m_cat->message(value()); } std::string message() const { return m_cat->message(value()); }
typedef void (*unspecified_bool_type)(); typedef void (*unspecified_bool_type)();
static void unspecified_bool_true() {} static void unspecified_bool_true() {}
operator unspecified_bool_type() const // true if error operator unspecified_bool_type() const BOOST_SYSTEM_NOEXCEPT // true if error
{ {
return m_val == 0 ? 0 : unspecified_bool_true; return m_val == 0 ? 0 : unspecified_bool_true;
} }
bool operator!() const // true if no error bool operator!() const BOOST_SYSTEM_NOEXCEPT // true if no error
{ {
return m_val == 0; return m_val == 0;
} }
@ -279,13 +287,13 @@ namespace boost
// the more symmetrical non-member syntax allows enum // the more symmetrical non-member syntax allows enum
// conversions work for both rhs and lhs. // conversions work for both rhs and lhs.
inline friend bool operator==( const error_condition & lhs, inline friend bool operator==( const error_condition & lhs,
const error_condition & rhs ) const error_condition & rhs ) BOOST_SYSTEM_NOEXCEPT
{ {
return lhs.m_cat == rhs.m_cat && lhs.m_val == rhs.m_val; return lhs.m_cat == rhs.m_cat && lhs.m_val == rhs.m_val;
} }
inline friend bool operator<( const error_condition & lhs, inline friend bool operator<( const error_condition & lhs,
const error_condition & rhs ) const error_condition & rhs ) BOOST_SYSTEM_NOEXCEPT
// the more symmetrical non-member syntax allows enum // the more symmetrical non-member syntax allows enum
// conversions work for both rhs and lhs. // conversions work for both rhs and lhs.
{ {
@ -312,59 +320,59 @@ namespace boost
public: public:
// constructors: // constructors:
error_code() : m_val(0), m_cat(&system_category()) {} error_code() BOOST_SYSTEM_NOEXCEPT : m_val(0), m_cat(&system_category()) {}
error_code( int val, const error_category & cat ) : m_val(val), m_cat(&cat) {} error_code( int val, const error_category & cat ) BOOST_SYSTEM_NOEXCEPT : m_val(val), m_cat(&cat) {}
template <class ErrorCodeEnum> template <class ErrorCodeEnum>
error_code(ErrorCodeEnum e, error_code(ErrorCodeEnum e,
typename boost::enable_if<is_error_code_enum<ErrorCodeEnum> >::type* = 0) typename boost::enable_if<is_error_code_enum<ErrorCodeEnum> >::type* = 0) BOOST_SYSTEM_NOEXCEPT
{ {
*this = make_error_code(e); *this = make_error_code(e);
} }
// modifiers: // modifiers:
void assign( int val, const error_category & cat ) void assign( int val, const error_category & cat ) BOOST_SYSTEM_NOEXCEPT
{ {
m_val = val; m_val = val;
m_cat = &cat; m_cat = &cat;
} }
template<typename ErrorCodeEnum> template<typename ErrorCodeEnum>
typename boost::enable_if<is_error_code_enum<ErrorCodeEnum>, error_code>::type & typename boost::enable_if<is_error_code_enum<ErrorCodeEnum>, error_code>::type &
operator=( ErrorCodeEnum val ) operator=( ErrorCodeEnum val ) BOOST_SYSTEM_NOEXCEPT
{ {
*this = make_error_code(val); *this = make_error_code(val);
return *this; return *this;
} }
void clear() void clear() BOOST_SYSTEM_NOEXCEPT
{ {
m_val = 0; m_val = 0;
m_cat = &system_category(); m_cat = &system_category();
} }
// observers: // observers:
int value() const { return m_val; } int value() const BOOST_SYSTEM_NOEXCEPT { return m_val; }
const error_category & category() const { return *m_cat; } const error_category & category() const BOOST_SYSTEM_NOEXCEPT { return *m_cat; }
error_condition default_error_condition() const { return m_cat->default_error_condition(value()); } error_condition default_error_condition() const BOOST_SYSTEM_NOEXCEPT { return m_cat->default_error_condition(value()); }
std::string message() const { return m_cat->message(value()); } std::string message() const { return m_cat->message(value()); }
typedef void (*unspecified_bool_type)(); typedef void (*unspecified_bool_type)();
static void unspecified_bool_true() {} static void unspecified_bool_true() {}
operator unspecified_bool_type() const // true if error operator unspecified_bool_type() const BOOST_SYSTEM_NOEXCEPT // true if error
{ {
return m_val == 0 ? 0 : unspecified_bool_true; return m_val == 0 ? 0 : unspecified_bool_true;
} }
bool operator!() const // true if no error bool operator!() const BOOST_SYSTEM_NOEXCEPT // true if no error
{ {
return m_val == 0; return m_val == 0;
} }
// relationals: // relationals:
inline friend bool operator==( const error_code & lhs, inline friend bool operator==( const error_code & lhs,
const error_code & rhs ) const error_code & rhs ) BOOST_SYSTEM_NOEXCEPT
// the more symmetrical non-member syntax allows enum // the more symmetrical non-member syntax allows enum
// conversions work for both rhs and lhs. // conversions work for both rhs and lhs.
{ {
@ -372,15 +380,15 @@ namespace boost
} }
inline friend bool operator<( const error_code & lhs, inline friend bool operator<( const error_code & lhs,
const error_code & rhs ) const error_code & rhs ) BOOST_SYSTEM_NOEXCEPT
// the more symmetrical non-member syntax allows enum // the more symmetrical non-member syntax allows enum
// conversions work for both rhs and lhs. // conversions work for both rhs and lhs.
{ {
return lhs.m_cat < rhs.m_cat return lhs.m_cat < rhs.m_cat
|| (lhs.m_cat == rhs.m_cat && lhs.m_val < rhs.m_val); || (lhs.m_cat == rhs.m_cat && lhs.m_val < rhs.m_val);
} }
private: private:
int m_val; int m_val;
const error_category * m_cat; const error_category * m_cat;
@ -414,43 +422,43 @@ namespace boost
// non-member functions ------------------------------------------------// // non-member functions ------------------------------------------------//
inline bool operator!=( const error_code & lhs, inline bool operator!=( const error_code & lhs,
const error_code & rhs ) const error_code & rhs ) BOOST_SYSTEM_NOEXCEPT
{ {
return !(lhs == rhs); return !(lhs == rhs);
} }
inline bool operator!=( const error_condition & lhs, inline bool operator!=( const error_condition & lhs,
const error_condition & rhs ) const error_condition & rhs ) BOOST_SYSTEM_NOEXCEPT
{ {
return !(lhs == rhs); return !(lhs == rhs);
} }
inline bool operator==( const error_code & code, inline bool operator==( const error_code & code,
const error_condition & condition ) const error_condition & condition ) BOOST_SYSTEM_NOEXCEPT
{ {
return code.category().equivalent( code.value(), condition ) return code.category().equivalent( code.value(), condition )
|| condition.category().equivalent( code, condition.value() ); || condition.category().equivalent( code, condition.value() );
} }
inline bool operator!=( const error_code & lhs, inline bool operator!=( const error_code & lhs,
const error_condition & rhs ) const error_condition & rhs ) BOOST_SYSTEM_NOEXCEPT
{ {
return !(lhs == rhs); return !(lhs == rhs);
} }
inline bool operator==( const error_condition & condition, inline bool operator==( const error_condition & condition,
const error_code & code ) const error_code & code ) BOOST_SYSTEM_NOEXCEPT
{ {
return condition.category().equivalent( code, condition.value() ) return condition.category().equivalent( code, condition.value() )
|| code.category().equivalent( code.value(), condition ); || code.category().equivalent( code.value(), condition );
} }
inline bool operator!=( const error_condition & lhs, inline bool operator!=( const error_condition & lhs,
const error_code & rhs ) const error_code & rhs ) BOOST_SYSTEM_NOEXCEPT
{ {
return !(lhs == rhs); return !(lhs == rhs);
} }
// TODO: both of these may move elsewhere, but the LWG hasn't spoken yet. // TODO: both of these may move elsewhere, but the LWG hasn't spoken yet.
template <class charT, class traits> template <class charT, class traits>
@ -472,29 +480,29 @@ namespace boost
namespace errc namespace errc
{ {
// explicit conversion: // explicit conversion:
inline error_code make_error_code( errc_t e ) inline error_code make_error_code( errc_t e ) BOOST_SYSTEM_NOEXCEPT
{ return error_code( e, generic_category() ); } { return error_code( e, generic_category() ); }
// implicit conversion: // implicit conversion:
inline error_condition make_error_condition( errc_t e ) inline error_condition make_error_condition( errc_t e ) BOOST_SYSTEM_NOEXCEPT
{ return error_condition( e, generic_category() ); } { return error_condition( e, generic_category() ); }
} }
// error_category default implementation -------------------------------// // error_category default implementation -------------------------------//
inline error_condition error_category::default_error_condition( int ev ) const error_condition error_category::default_error_condition( int ev ) const BOOST_SYSTEM_NOEXCEPT
{ {
return error_condition( ev, *this ); return error_condition( ev, *this );
} }
inline bool error_category::equivalent( int code, bool error_category::equivalent( int code,
const error_condition & condition ) const const error_condition & condition ) const BOOST_SYSTEM_NOEXCEPT
{ {
return default_error_condition( code ) == condition; return default_error_condition( code ) == condition;
} }
inline bool error_category::equivalent( const error_code & code, bool error_category::equivalent( const error_code & code,
int condition ) const int condition ) const BOOST_SYSTEM_NOEXCEPT
{ {
return *this == code.category() && code.value() == condition; return *this == code.category() && code.value() == condition;
} }

View File

@ -21,7 +21,7 @@ namespace boost
class BOOST_SYMBOL_VISIBLE system_error : public std::runtime_error class BOOST_SYMBOL_VISIBLE system_error : public std::runtime_error
// BOOST_SYMBOL_VISIBLE is needed by GCC to ensure system_error thrown from a shared // BOOST_SYMBOL_VISIBLE is needed by GCC to ensure system_error thrown from a shared
// library can be caught. See svn.boost.org/trac/boost/ticket/3697 // library can be caught. See svn.boost.org/trac/boost/ticket/3697
{ {
public: public:
system_error( error_code ec ) system_error( error_code ec )
@ -61,13 +61,17 @@ namespace boost
{ {
if ( m_what.empty() ) if ( m_what.empty() )
{ {
#ifndef BOOST_NO_EXCEPTIONS
try try
#endif
{ {
m_what = this->std::runtime_error::what(); m_what = this->std::runtime_error::what();
if ( !m_what.empty() ) m_what += ": "; if ( !m_what.empty() ) m_what += ": ";
m_what += m_error_code.message(); m_what += m_error_code.message();
} }
#ifndef BOOST_NO_EXCEPTIONS
catch (...) { return std::runtime_error::what(); } catch (...) { return std::runtime_error::what(); }
#endif
} }
return m_what.c_str(); return m_what.c_str();
} }

View File

@ -22,9 +22,6 @@
#include <cstdlib> #include <cstdlib>
#include <cassert> #include <cassert>
using namespace boost::system;
using namespace boost::system::errc;
#include <cstring> // for strerror/strerror_r #include <cstring> // for strerror/strerror_r
# if defined( BOOST_WINDOWS_API ) # if defined( BOOST_WINDOWS_API )
@ -36,19 +33,21 @@ using namespace boost::system::errc;
# endif # endif
//----------------------------------------------------------------------------// //----------------------------------------------------------------------------//
namespace boost
{
namespace system
{
namespace namespace
{ {
#if defined(__PGI)
using boost::system::errc::invalid_argument;
#endif
// standard error categories ---------------------------------------------// // standard error categories ---------------------------------------------//
class generic_error_category : public error_category class generic_error_category : public error_category
{ {
public: public:
generic_error_category(){} generic_error_category(){}
const char * name() const; const char * name() const BOOST_SYSTEM_NOEXCEPT;
std::string message( int ev ) const; std::string message( int ev ) const;
}; };
@ -56,20 +55,25 @@ namespace
{ {
public: public:
system_error_category(){} system_error_category(){}
const char * name() const; const char * name() const BOOST_SYSTEM_NOEXCEPT;
std::string message( int ev ) const; std::string message( int ev ) const;
error_condition default_error_condition( int ev ) const; error_condition default_error_condition( int ev ) const BOOST_SYSTEM_NOEXCEPT;
}; };
// generic_error_category implementation ---------------------------------// // generic_error_category implementation ---------------------------------//
const char * generic_error_category::name() const const char * generic_error_category::name() const BOOST_SYSTEM_NOEXCEPT
{ {
return "generic"; return "generic";
} }
std::string generic_error_category::message( int ev ) const std::string generic_error_category::message( int ev ) const
{ {
using namespace boost::system::errc;
#if defined(__PGI)
using boost::system::errc::invalid_argument;
#endif
static std::string unknown_err( "Unknown error" ); static std::string unknown_err( "Unknown error" );
// strerror_r is preferred because it is always thread safe, // strerror_r is preferred because it is always thread safe,
// however, we fallback to strerror in certain cases because: // however, we fallback to strerror in certain cases because:
@ -133,7 +137,9 @@ namespace
} }
} }
std::string msg; std::string msg;
# ifndef BOOST_NO_EXCEPTIONS
try try
# endif
{ {
msg = ( ( result == invalid_argument ) ? "Unknown error" : bp ); msg = ( ( result == invalid_argument ) ? "Unknown error" : bp );
} }
@ -154,13 +160,18 @@ namespace
} }
// system_error_category implementation --------------------------------// // system_error_category implementation --------------------------------//
const char * system_error_category::name() const const char * system_error_category::name() const BOOST_SYSTEM_NOEXCEPT
{ {
return "system"; return "system";
} }
error_condition system_error_category::default_error_condition( int ev ) const error_condition system_error_category::default_error_condition( int ev ) const BOOST_SYSTEM_NOEXCEPT
{ {
using namespace boost::system::errc;
#if defined(__PGI)
using boost::system::errc::invalid_argument;
#endif
switch ( ev ) switch ( ev )
{ {
case 0: return make_error_condition( success ); case 0: return make_error_condition( success );
@ -401,10 +412,6 @@ namespace
} // unnamed namespace } // unnamed namespace
namespace boost
{
namespace system
{
# ifndef BOOST_SYSTEM_NO_DEPRECATED # ifndef BOOST_SYSTEM_NO_DEPRECATED
BOOST_SYSTEM_DECL error_code throws; // "throw on error" special error_code; BOOST_SYSTEM_DECL error_code throws; // "throw on error" special error_code;
@ -414,13 +421,13 @@ namespace boost
// address for comparison purposes // address for comparison purposes
# endif # endif
BOOST_SYSTEM_DECL const error_category & system_category() BOOST_SYSTEM_DECL const error_category & system_category() BOOST_SYSTEM_NOEXCEPT
{ {
static const system_error_category system_category_const; static const system_error_category system_category_const;
return system_category_const; return system_category_const;
} }
BOOST_SYSTEM_DECL const error_category & generic_category() BOOST_SYSTEM_DECL const error_category & generic_category() BOOST_SYSTEM_NOEXCEPT
{ {
static const generic_error_category generic_category_const; static const generic_error_category generic_category_const;
return generic_category_const; return generic_category_const;

View File

@ -75,7 +75,7 @@ namespace boost
namespace lib3 namespace lib3
{ {
// lib3 has its own error_category: // lib3 has its own error_category:
const boost::system::error_category & get_lib3_error_category(); const boost::system::error_category & get_lib3_error_category() BOOST_SYSTEM_NOEXCEPT;
const boost::system::error_category & lib3_error_category = get_lib3_error_category(); const boost::system::error_category & lib3_error_category = get_lib3_error_category();
enum error enum error
@ -112,12 +112,12 @@ namespace boost
public: public:
lib3_error_category_imp() : boost::system::error_category() { } lib3_error_category_imp() : boost::system::error_category() { }
const char * name() const const char * name() const BOOST_SYSTEM_NOEXCEPT
{ {
return "lib3"; return "lib3";
} }
boost::system::error_condition default_error_condition( int ev ) const boost::system::error_condition default_error_condition( int ev ) const BOOST_SYSTEM_NOEXCEPT
{ {
return ev == boo_boo return ev == boo_boo
? boost::system::error_condition( boost::system::errc::io_error, ? boost::system::error_condition( boost::system::errc::io_error,
@ -135,7 +135,7 @@ namespace boost
}; };
const boost::system::error_category & get_lib3_error_category() const boost::system::error_category & get_lib3_error_category() BOOST_SYSTEM_NOEXCEPT
{ {
static const lib3_error_category_imp l3ecat; static const lib3_error_category_imp l3ecat;
return l3ecat; return l3ecat;
@ -156,7 +156,7 @@ namespace boost
namespace lib4 namespace lib4
{ {
// lib4 has its own error_category: // lib4 has its own error_category:
const boost::system::error_category & get_lib4_error_category(); const boost::system::error_category & get_lib4_error_category() BOOST_SYSTEM_NOEXCEPT;
const boost::system::error_category & lib4_error_category = get_lib4_error_category(); const boost::system::error_category & lib4_error_category = get_lib4_error_category();
extern const boost::system::error_code boo_boo; extern const boost::system::error_code boo_boo;
@ -174,12 +174,12 @@ namespace lib4
public: public:
lib4_error_category_imp() : boost::system::error_category() { } lib4_error_category_imp() : boost::system::error_category() { }
const char * name() const const char * name() const BOOST_SYSTEM_NOEXCEPT
{ {
return "lib4"; return "lib4";
} }
boost::system::error_condition default_error_condition( int ev ) const boost::system::error_condition default_error_condition( int ev ) const BOOST_SYSTEM_NOEXCEPT
{ {
return ev == boo_boo.value() return ev == boo_boo.value()
? boost::system::error_condition( boost::system::errc::io_error, ? boost::system::error_condition( boost::system::errc::io_error,
@ -195,7 +195,7 @@ namespace lib4
} }
}; };
const boost::system::error_category & get_lib4_error_category() const boost::system::error_category & get_lib4_error_category() BOOST_SYSTEM_NOEXCEPT
{ {
static const lib4_error_category_imp l4ecat; static const lib4_error_category_imp l4ecat;
return l4ecat; return l4ecat;