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>
<td width="100%" bgcolor="#E8F5FF">
<a href="#Introduction">Introduction</a><br>
<a href="#C++11">C++11</a><br>
<a href="#Macros">Macros</a><br>
<a href="#Deprecated-names">Deprecated names</a><br>
<a href="#Breaking-changes">Breaking changes</a><br>
@ -70,11 +71,15 @@
<h2><a name="Introduction">Introduction</a></h2>
<p>This reference documentation describes components that&nbsp;
programs may use to report error conditions originating from the operating
<p>This reference documentation describes components that&nbsp;programs may use to report error conditions originating from the operating
system or other low-level application program interfaces.</p>
<p>Boost.System library components never change the value of <code>
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>
<p>Users may defined the following macros if desired. Sensible defaults are
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
{
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_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>
bool operator==( const error_code &amp; lhs, const error_code &amp; rhs );
bool operator==( const error_code &amp; code, const error_condition &amp; condition );
bool operator==( const error_condition &amp; condition, const error_code &amp; code );
bool operator==( const error_condition &amp; lhs, const error_condition &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 ) noexcept;
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 ) noexcept;
bool operator!=( const error_code &amp; lhs, const error_code &amp; rhs );
bool operator!=( const error_code &amp; code, const error_condition &amp; condition );
bool operator!=( const error_condition &amp; condition, const error_code &amp; code );
bool operator!=( const error_condition &amp; lhs, const error_condition &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 ) noexcept;
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 ) noexcept;
bool operator&lt;( const error_code &amp; lhs, const error_code &amp; rhs );
bool operator&lt;( const error_condition &amp; lhs, const error_condition &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 ) noexcept;
error_code make_error_code( errc::errc_t e );
error_condition make_error_condition( errc::errc_t e );
error_code make_error_code( errc::errc_t e ) noexcept;
error_condition make_error_condition( errc::errc_t e ) noexcept;
template &lt;class charT, class traits&gt;
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
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>
<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>
@ -336,37 +355,33 @@ types should create a single object of each such type. <i>
public:
virtual ~error_category();
virtual const char * name() const = 0;
virtual const char * name() const noexcept = 0;
virtual string message( int ev ) const = 0;
virtual error_condition default_error_condition( int ev ) const;
virtual bool equivalent( int code, const error_condition &amp; condition ) const;
virtual bool equivalent( const error_code &amp; code, int condition ) const;
virtual error_condition default_error_condition( int ev ) const noexcept;
virtual bool equivalent( int code, const error_condition &amp; condition )
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;
bool operator&lt; ( const error_category &amp; rhs ) const;
bool operator==( const error_category &amp; rhs ) const noexcept;
bool operator!=( const error_category &amp; rhs ) const noexcept;
bool operator&lt; ( const error_category &amp; rhs ) const noexcept;
};
const error_category &amp; system_category();
const error_category &amp; generic_category();
}
}</pre>
</blockquote>
<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
this subclause.</p>
<pre>virtual const char * name() const=0;</pre>
<pre>virtual const char * name() const noexcept =0;</pre>
<blockquote>
<p><i>Returns: </i>a string naming the error category.</p>
<p><i>Throws:</i> Nothing.</p>
</blockquote>
<pre>virtual string message( int ev ) const=0;</pre>
<pre>virtual string message( int ev ) const noexcept =0;</pre>
<blockquote>
<p><i>Returns:</i> A string that describes the error denoted by
<code>ev</code>.</p>
<p><i>Throws:</i> Nothing.</p>
</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>
<p><i>Returns:</i>&nbsp; <code>error_condition( ev, *this )</code>.</p>
<blockquote>
@ -375,52 +390,33 @@ this subclause.</p>
and return it as an <code>error_condition</code> for that category. <i>--end
note</i>]</p>
</blockquote>
<p><i>Throws:</i> Nothing.</p>
</blockquote>
<p><code>virtual bool equivalent( int code, const error_condition &amp;
condition )
const;</code></p>
</blockquote>
<pre>virtual bool equivalent( int code, const error_condition &amp; condition ) const noexcept;</pre>
<blockquote>
<p><i>Returns:</i> <code>default_error_condition( code ) == condition</code>.</p>
<p><i>Throws:</i> Nothing.</p>
</blockquote>
<p><code>virtual bool equivalent( const error_code &amp; code, int condition ) const;</code></p>
</blockquote>
<pre>virtual bool equivalent( const error_code &amp; code, int condition ) const noexcept;</pre>
<blockquote>
<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>
<p><code>bool operator==( const error_category &amp; rhs ) const;</code></p>
<pre>bool operator==( const error_category &amp; rhs ) const noexcept;</pre>
<blockquote>
<p><i>Returns:</i> <code>this == &amp;rhs</code>.</p>
</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>
<p><i>Returns:</i> <code>this != &amp;rhs</code>.</p>
</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>
<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>
<p><i>[Note:</i> <code>std::less</code> provides a total ordering for
pointers. <i>--end note]</i></p>
</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>
<h2><a name="Class-error_code">Class <code>
error_code</code></a></h2>
@ -440,21 +436,21 @@ error_code</code> synopsis</a></h3>
public:
// constructors:
error_code();
error_code( val, const error_category &amp; cat );
error_code() noexcept;
error_code( val, const error_category &amp; cat ) noexcept;
template &lt;class <code>ErrorCodeEnum</code>&gt;
error_code(<code> ErrorCodeEnum</code> e );
error_code(<code> ErrorCodeEnum</code> e ) noexcept;
// 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;
error_code &amp; operator=( <code>ErrorCodeEnum</code> val );;
void clear();
error_code &amp; operator=( <code>ErrorCodeEnum</code> val ) noexcept;
void clear() noexcept;
// observers:
int value() const;
cont error_category &amp; category() const;
error_condition default_error_condition() const;
int value() const noexcept;
cont error_category &amp; category() const noexcept;
error_condition default_error_condition() const noexcept;
string message() const;
operator unspecified-bool-type() const;
@ -467,71 +463,63 @@ error_code</code> synopsis</a></h3>
</blockquote>
<h3><a name="Class-error_code-constructors">Class <code>
error_code</code> constructors</a></h3>
<pre>error_code();</pre>
<pre>error_code() noexcept;</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;system_category()</code>.</p>
<p><i>Throws:</i> Nothing.</p>
</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>
<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>template &lt;class <code>ErrorCodeEnum</code>&gt;
error_code(<code> ErrorCodeEnum</code> val );</pre>
error_code(<code> ErrorCodeEnum</code> val ) noexcept;</pre>
<blockquote>
<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>Throws:</i> Nothing.</p>
<p><i>Remarks:</i> This constructor shall not participate in overload
resolution unless <code>is_error_code_enum&lt;ErrorCodeEnum&gt;::value</code> is
<code>true</code>.</p>
</blockquote>
<h3><a name="Class-error_code-modifiers">Class <code>
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>
<p><i>Postconditions:</i> <code>val_ == val &amp;&amp; cat_ == &amp;cat</code>.</p>
<p><i>Throws:</i> Nothing.</p>
</blockquote>
<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>
<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
unless <code>is_error_code_enum&lt;ErrorCodeEnum&gt;::value</code> is <code>true</code>.</p>
</blockquote>
<p><code>void clear();</code></p>
<pre><code>void clear() noexcept;</code></pre>
<blockquote>
<p><i>postcondition:</i> <code>value() == 0 &amp;&amp; category() ==
system_category()</code></p>
</blockquote>
<h3><a name="Class-error_code-observers">Class <code>
error_code</code> observers</a></h3>
<p><code>int value() const;</code></p>
<pre><code>int value() const noexcept;</code></pre>
<blockquote>
<p><i>Returns:</i> <code>val_</code>.</p>
<p><i>Throws:</i> Nothing.</p>
</blockquote>
<p><code>const error_category &amp; category() const;</code></p>
</blockquote>
<pre><code>const error_category &amp; category() const noexcept;</code></pre>
<blockquote>
<p><i>Returns:</i> <code>*cat_</code>.</p>
<p><i>Throws:</i> Nothing.</p>
</blockquote>
<pre>error_condition default_error_condition() const;</pre>
</blockquote>
<pre>error_condition default_error_condition() const noexcept;</pre>
<blockquote>
<p><i>Returns:</i>&nbsp; <code>category().default_error_condition( value())</code>.</p>
<p><i>Throws:</i> Nothing.</p>
</blockquote>
<p><code>string message() const;</code></p>
<pre><code>string message() const;</code></pre>
<blockquote>
<p><i>Returns:</i>&nbsp; <code>category().message( value())</code>.</p>
<p><i>Throws:</i> Nothing.</p>
</blockquote>
<p><code>operator <i>unspecified-bool-type</i>() const;</code></p>
<pre>operator unspecified-bool-type() const;</pre>
<blockquote>
<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
@ -560,22 +548,22 @@ implementation specific. <i>--end note ]</i></p>
public:
// constructors:
error_condition();
error_condition( int val, const error_category &amp; cat );
error_condition() noexcept;
error_condition( int val, const error_category &amp; cat ) noexcept;
template &lt;class ErrorConditionEnum&gt;
error_condition( errorConditionEnum val );
error_condition( errorConditionEnum val ) noexcept;
// 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;
error_condition &amp; operator=( ErrorConditionEnum val );
void clear();
error_condition &amp; operator=( ErrorConditionEnum val ) noexcept;
void clear() noexcept;
// observers:
int value() const;
const error_category &amp; category() const;
int value() const noexcept;
const error_category &amp; category() const noexcept;
string message() const;
operator unspecified-bool-type () const;
operator unspecified-bool-type () const noexcept;
private:
int val_; // <i>exposition only</i>
@ -586,65 +574,57 @@ implementation specific. <i>--end note ]</i></p>
</blockquote>
<h3><a name="Class-error_condition-constructors">Class <code>error_condition</code>
constructors</a></h3>
<pre>error_condition(); </pre>
<pre>error_condition() noexcept; </pre>
<blockquote>
<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>Throws:</i> Nothing.</p>
</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>
<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>Throws:</i> Nothing.</p>
</blockquote>
<pre>template &lt;class ErrorConditionEnum&gt;
error_condition( ErrorConditionEnum e );</pre>
error_condition( ErrorConditionEnum e ) noexcept;</pre>
<blockquote>
<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>Throws:</i> Nothing.</p>
<p><i>Remarks:</i> This constructor shall not participate in overload
resolution unless <code>is_error_condition_enum&lt;ErrorConditionEnum&gt;::value</code>
is <code>true</code>.</p>
</blockquote>
<h3><a name="Class-error_condition-modifiers">Class <code>error_condition</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>
<p><i>Postconditions:</i> <code>val_ == val and cat_ == &amp;cat</code>. </p>
<p><i>Throws:</i> Nothing.</p>
</blockquote>
<pre>template&lt;typename ErrorConditionEnum&gt;
error_condition &amp; operator=( ErrorConditionEnum e );</pre>
error_condition &amp; operator=( ErrorConditionEnum e ) noexcept;</pre>
<blockquote>
<p><i>Postconditions:</i> <code>*this == make_error_condition( e )</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
unless <code>is_error_condition_enum&lt;ErrorConditionEnum&gt;::value</code> is
<code>true</code>.</p>
</blockquote>
<p><code>void clear();</code></p>
<pre>void clear() noexcept;</pre>
<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>
<h3><a name="Class-error_condition-observers">Class <code>error_condition</code>
observers</a></h3>
<pre>int value() const;</pre>
<pre>int value() const noexcept;</pre>
<blockquote>
<p><i>Returns:</i> <code>val_</code>.</p>
<p><i>Throws:</i> Nothing</p>
</blockquote>
<pre>const error_category &amp; category() const;</pre>
<pre>const error_category &amp; category() const noexcept;</pre>
<blockquote>
<p><i>Returns:</i> <code>*cat_</code>.</p>
<p>Throws: Nothing.</p>
</blockquote>
<pre>string message() const;</pre>
<blockquote>
<p><i>Returns:</i> <code>category().message( value() )</code>.</p>
<p><i>Throws:</i> Nothing.</p>
</blockquote>
<pre>operator unspecified-bool-type () const;</pre>
<blockquote>
@ -690,58 +670,50 @@ semantics:</p>
</blockquote>
</blockquote>
<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>
<p><i>Returns:</i> <code>lhs.category() == rhs.category() &amp;&amp; lhs.value() ==
rhs.value()</code>.</p>
<p><i>Throws: </i>Nothing.</p>
</blockquote>
<pre>bool operator==( const error_code &amp; code, const error_condition &amp; condition );
bool operator==( const error_condition &amp; condition, const error_code &amp; code );</pre>
<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 ) noexcept;</pre>
<blockquote>
<p><i>Returns:</i> <code>code.category().equivalent( code.value(), condition )<br>
|| condition.category().equivalent( code, condition.value() )</code>.</p>
<p><i>Throws: </i>Nothing.</p>
</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>
<p><i>Returns:</i> <code>lhs.category() == rhs.category() &amp;&amp; lhs.value() ==
rhs.value()</code>.</p>
<p><i>Throws: </i>Nothing.</p>
</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>
<p><i>Returns:</i> <code>!(lhs == rhs )</code>.</p>
<p><i>Throws: </i>Nothing.</p>
</blockquote>
<pre>bool operator!=( const error_code &amp; code, const error_condition &amp; condition );
bool operator!=( const error_condition &amp; condition, const error_code &amp; code );</pre>
<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 ) noexcept;</pre>
<blockquote>
<p><i>Returns:</i><code> !( code ==&nbsp; condition )</code>.</p>
<p><i>Throws: </i>Nothing.</p>
</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>
<p><i>Returns:</i> <code>!(lhs == rhs )</code>.</p>
<p><i>Throws: </i>Nothing.</p>
</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>
<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>
<p><i>Throws: </i>Nothing.</p>
</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>
<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>
<p><i>Throws: </i>Nothing.</p>
</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>
<p><i>Returns:</i> <code>error_code( e, generic_category())</code>.</p>
</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>
<p><i>Returns:</i> <code>error_condition( static_cast&lt;int&gt;( e ), generic_category())</code>.</p>
</blockquote>
@ -840,10 +812,10 @@ application program interfaces.</p>
<hr>
<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><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
<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>
// 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)
# 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
#ifndef BOOST_SYSTEM_NOEXCEPT
#define BOOST_SYSTEM_NOEXCEPT BOOST_NOEXCEPT
#endif
namespace boost
{
namespace system
@ -184,17 +188,17 @@ namespace boost
public:
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 error_condition default_error_condition( int ev ) const;
virtual bool equivalent( int code,
const error_condition & condition ) const;
virtual bool equivalent( const error_code & code,
int condition ) const;
inline virtual error_condition default_error_condition( int ev ) const BOOST_SYSTEM_NOEXCEPT;
inline virtual bool equivalent( int code,
const error_condition & condition ) const BOOST_SYSTEM_NOEXCEPT;
inline virtual bool equivalent( const error_code & code,
int condition ) const BOOST_SYSTEM_NOEXCEPT;
bool operator==(const error_category & rhs) const { return this == &rhs; }
bool operator!=(const error_category & rhs) const { return this != &rhs; }
bool operator<( const error_category & rhs ) const
bool operator==(const error_category & rhs) const BOOST_SYSTEM_NOEXCEPT { return this == &rhs; }
bool operator!=(const error_category & rhs) const BOOST_SYSTEM_NOEXCEPT { return this != &rhs; }
bool operator<( const error_category & rhs ) const BOOST_SYSTEM_NOEXCEPT
{
return std::less<const error_category*>()( this, &rhs );
}
@ -202,9 +206,13 @@ namespace boost
// predefined error categories -----------------------------------------//
BOOST_SYSTEM_DECL const error_category & system_category();
BOOST_SYSTEM_DECL const error_category & generic_category();
# ifdef BOOST_ERROR_CODE_HEADER_ONLY
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 --------------------------------------------------//
# ifndef BOOST_SYSTEM_NO_DEPRECATED
@ -225,52 +233,52 @@ namespace boost
public:
// constructors:
error_condition() : m_val(0), m_cat(&generic_category()) {}
error_condition( int val, const error_category & cat ) : m_val(val), m_cat(&cat) {}
error_condition() BOOST_SYSTEM_NOEXCEPT : m_val(0), m_cat(&generic_category()) {}
error_condition( int val, const error_category & cat ) BOOST_SYSTEM_NOEXCEPT : m_val(val), m_cat(&cat) {}
template <class ErrorConditionEnum>
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);
}
// modifiers:
void assign( int val, const error_category & cat )
{
void assign( int val, const error_category & cat ) BOOST_SYSTEM_NOEXCEPT
{
m_val = val;
m_cat = &cat;
}
template<typename ErrorConditionEnum>
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);
return *this;
}
void clear()
void clear() BOOST_SYSTEM_NOEXCEPT
{
m_val = 0;
m_cat = &generic_category();
}
// observers:
int value() const { return m_val; }
const error_category & category() const { return *m_cat; }
int value() const BOOST_SYSTEM_NOEXCEPT { return m_val; }
const error_category & category() const BOOST_SYSTEM_NOEXCEPT { return *m_cat; }
std::string message() const { return m_cat->message(value()); }
typedef void (*unspecified_bool_type)();
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;
}
bool operator!() const // true if no error
bool operator!() const BOOST_SYSTEM_NOEXCEPT // true if no error
{
return m_val == 0;
}
@ -279,13 +287,13 @@ namespace boost
// the more symmetrical non-member syntax allows enum
// conversions work for both rhs and 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;
}
}
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
// conversions work for both rhs and lhs.
{
@ -312,59 +320,59 @@ namespace boost
public:
// constructors:
error_code() : m_val(0), m_cat(&system_category()) {}
error_code( int val, const error_category & cat ) : m_val(val), m_cat(&cat) {}
error_code() BOOST_SYSTEM_NOEXCEPT : m_val(0), m_cat(&system_category()) {}
error_code( int val, const error_category & cat ) BOOST_SYSTEM_NOEXCEPT : m_val(val), m_cat(&cat) {}
template <class ErrorCodeEnum>
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);
}
// modifiers:
void assign( int val, const error_category & cat )
{
void assign( int val, const error_category & cat ) BOOST_SYSTEM_NOEXCEPT
{
m_val = val;
m_cat = &cat;
}
template<typename ErrorCodeEnum>
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);
return *this;
}
void clear()
void clear() BOOST_SYSTEM_NOEXCEPT
{
m_val = 0;
m_cat = &system_category();
}
// observers:
int value() const { return m_val; }
const error_category & category() const { return *m_cat; }
error_condition default_error_condition() const { return m_cat->default_error_condition(value()); }
int value() const BOOST_SYSTEM_NOEXCEPT { return m_val; }
const error_category & category() const BOOST_SYSTEM_NOEXCEPT { return *m_cat; }
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()); }
typedef void (*unspecified_bool_type)();
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;
}
bool operator!() const // true if no error
bool operator!() const BOOST_SYSTEM_NOEXCEPT // true if no error
{
return m_val == 0;
}
// relationals:
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
// conversions work for both rhs and lhs.
{
@ -372,15 +380,15 @@ namespace boost
}
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
// conversions work for both rhs and lhs.
{
return lhs.m_cat < rhs.m_cat
|| (lhs.m_cat == rhs.m_cat && lhs.m_val < rhs.m_val);
}
private:
private:
int m_val;
const error_category * m_cat;
@ -414,43 +422,43 @@ namespace boost
// non-member functions ------------------------------------------------//
inline bool operator!=( const error_code & lhs,
const error_code & rhs )
const error_code & rhs ) BOOST_SYSTEM_NOEXCEPT
{
return !(lhs == rhs);
}
inline bool operator!=( const error_condition & lhs,
const error_condition & rhs )
const error_condition & rhs ) BOOST_SYSTEM_NOEXCEPT
{
return !(lhs == rhs);
}
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 )
|| condition.category().equivalent( code, condition.value() );
}
inline bool operator!=( const error_code & lhs,
const error_condition & rhs )
const error_condition & rhs ) BOOST_SYSTEM_NOEXCEPT
{
return !(lhs == rhs);
}
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() )
|| code.category().equivalent( code.value(), condition );
}
inline bool operator!=( const error_condition & lhs,
const error_code & rhs )
const error_code & rhs ) BOOST_SYSTEM_NOEXCEPT
{
return !(lhs == rhs);
}
// TODO: both of these may move elsewhere, but the LWG hasn't spoken yet.
template <class charT, class traits>
@ -472,29 +480,29 @@ namespace boost
namespace errc
{
// 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() ); }
// 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() ); }
}
// 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 );
}
inline bool error_category::equivalent( int code,
const error_condition & condition ) const
bool error_category::equivalent( int code,
const error_condition & condition ) const BOOST_SYSTEM_NOEXCEPT
{
return default_error_condition( code ) == condition;
}
inline bool error_category::equivalent( const error_code & code,
int condition ) const
bool error_category::equivalent( const error_code & code,
int condition ) const BOOST_SYSTEM_NOEXCEPT
{
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
// 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:
system_error( error_code ec )
@ -61,13 +61,17 @@ namespace boost
{
if ( m_what.empty() )
{
#ifndef BOOST_NO_EXCEPTIONS
try
#endif
{
m_what = this->std::runtime_error::what();
if ( !m_what.empty() ) m_what += ": ";
m_what += m_error_code.message();
}
#ifndef BOOST_NO_EXCEPTIONS
catch (...) { return std::runtime_error::what(); }
#endif
}
return m_what.c_str();
}

View File

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

View File

@ -75,7 +75,7 @@ namespace boost
namespace lib3
{
// 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();
enum error
@ -112,12 +112,12 @@ namespace boost
public:
lib3_error_category_imp() : boost::system::error_category() { }
const char * name() const
const char * name() const BOOST_SYSTEM_NOEXCEPT
{
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
? 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;
return l3ecat;
@ -156,7 +156,7 @@ namespace boost
namespace lib4
{
// 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();
extern const boost::system::error_code boo_boo;
@ -174,12 +174,12 @@ namespace lib4
public:
lib4_error_category_imp() : boost::system::error_category() { }
const char * name() const
const char * name() const BOOST_SYSTEM_NOEXCEPT
{
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()
? 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;
return l4ecat;