|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r83550 - in branches/release: boost/filesystem boost/system libs/filesystem libs/filesystem/src libs/system libs/system/doc libs/system/src libs/system/test
From: vicente.botet_at_[hidden]
Date: 2013-03-24 16:20:30
Author: viboes
Date: 2013-03-24 16:20:29 EDT (Sun, 24 Mar 2013)
New Revision: 83550
URL: http://svn.boost.org/trac/boost/changeset/83550
Log:
System/FileSystem: merge from trunk to fix #7278.
Properties modified:
branches/release/boost/filesystem/ (props changed)
branches/release/boost/system/ (props changed)
branches/release/libs/filesystem/ (props changed)
branches/release/libs/system/ (props changed)
Text files modified:
branches/release/boost/system/error_code.hpp | 144 ++++++++++++----------
branches/release/boost/system/system_error.hpp | 6
branches/release/libs/filesystem/src/codecvt_error_category.cpp | 4
branches/release/libs/system/doc/reference.html | 248 +++++++++++++++++----------------------
branches/release/libs/system/src/error_code.cpp | 43 ++++--
branches/release/libs/system/test/error_code_user_test.cpp | 16 +-
6 files changed, 226 insertions(+), 235 deletions(-)
Modified: branches/release/boost/system/error_code.hpp
==============================================================================
--- branches/release/boost/system/error_code.hpp (original)
+++ branches/release/boost/system/error_code.hpp 2013-03-24 16:20:29 EDT (Sun, 24 Mar 2013)
@@ -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 @@
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;
-
- 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
+ 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 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 @@
// 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 @@
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 @@
// 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 @@
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 @@
}
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 @@
// 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 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;
}
Modified: branches/release/boost/system/system_error.hpp
==============================================================================
--- branches/release/boost/system/system_error.hpp (original)
+++ branches/release/boost/system/system_error.hpp 2013-03-24 16:20:29 EDT (Sun, 24 Mar 2013)
@@ -21,7 +21,7 @@
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 @@
{
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();
}
Modified: branches/release/libs/filesystem/src/codecvt_error_category.cpp
==============================================================================
--- branches/release/libs/filesystem/src/codecvt_error_category.cpp (original)
+++ branches/release/libs/filesystem/src/codecvt_error_category.cpp 2013-03-24 16:20:29 EDT (Sun, 24 Mar 2013)
@@ -35,11 +35,11 @@
{
public:
codecvt_error_cat(){}
- const char* name() const;
+ const char* name() const BOOST_SYSTEM_NOEXCEPT;
std::string message(int ev) const;
};
- const char* codecvt_error_cat::name() const
+ const char* codecvt_error_cat::name() const BOOST_SYSTEM_NOEXCEPT
{
return "codecvt";
}
Modified: branches/release/libs/system/doc/reference.html
==============================================================================
--- branches/release/libs/system/doc/reference.html (original)
+++ branches/release/libs/system/doc/reference.html 2013-03-24 16:20:29 EDT (Sun, 24 Mar 2013)
@@ -38,6 +38,7 @@
<tr>
<td width="100%" bgcolor="#E8F5FF">
<a href="#Introduction">Introduction</a><br>
+ C++11<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
-programs may use to report error conditions originating from the operating
+<p>This reference documentation describes components that 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 @@
namespace system
{
class error_category;
+ const error_category & system_category() noexcept;
+ const error_category & generic_category() noexcept;
+
class error_code;
class error_condition;
@@ -281,21 +289,21 @@
// non-member functions
- bool operator==( const error_code & lhs, const error_code & rhs );
- bool operator==( const error_code & code, const error_condition & condition );
- bool operator==( const error_condition & condition, const error_code & code );
- bool operator==( const error_condition & lhs, const error_condition & rhs );
-
- bool operator!=( const error_code & lhs, const error_code & rhs );
- bool operator!=( const error_code & code, const error_condition & condition );
- bool operator!=( const error_condition & condition, const error_code & code );
- bool operator!=( const error_condition & lhs, const error_condition & rhs );
+ bool operator==( const error_code & lhs, const error_code & rhs ) noexcept;
+ bool operator==( const error_code & code, const error_condition & condition ) noexcept;
+ bool operator==( const error_condition & condition, const error_code & code ) noexcept;
+ bool operator==( const error_condition & lhs, const error_condition & rhs ) noexcept;
+
+ bool operator!=( const error_code & lhs, const error_code & rhs ) noexcept;
+ bool operator!=( const error_code & code, const error_condition & condition ) noexcept;
+ bool operator!=( const error_condition & condition, const error_code & code ) noexcept;
+ bool operator!=( const error_condition & lhs, const error_condition & rhs ) noexcept;
- bool operator<( const error_code & lhs, const error_code & rhs );
- bool operator<( const error_condition & lhs, const error_condition & rhs );
+ bool operator<( const error_code & lhs, const error_code & rhs ) noexcept;
+ bool operator<( const error_condition & lhs, const error_condition & 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 <class charT, class traits>
std::basic_ostream<charT,traits>&
@@ -312,6 +320,17 @@
class <code>error_code</code> and <code>error_condition</code> automatic
conversions respectively.</p>
+<pre>const error_category & <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 & <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 @@
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 & condition ) const;
- virtual bool equivalent( const error_code & code, int condition ) const;
-
- bool operator==( const error_category & rhs ) const;
- bool operator!=( const error_category & rhs ) const;
- bool operator< ( const error_category & rhs ) const;
+ virtual error_condition default_error_condition( int ev ) const noexcept;
+ virtual bool equivalent( int code, const error_condition & condition )
+ const noexcept;
+ virtual bool equivalent( const error_code & code, int condition ) const noexcept;
+
+ bool operator==( const error_category & rhs ) const noexcept;
+ bool operator!=( const error_category & rhs ) const noexcept;
+ bool operator< ( const error_category & rhs ) const noexcept;
};
-
- const error_category & system_category();
- const error_category & 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> <code>error_condition( ev, *this )</code>.</p>
<blockquote>
@@ -375,52 +390,33 @@
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 &
-condition )
-const;</code></p>
+ </blockquote>
+<pre>virtual bool equivalent( int code, const error_condition & 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 & code, int condition ) const;</code></p>
+ </blockquote>
+<pre>virtual bool equivalent( const error_code & code, int condition ) const noexcept;</pre>
<blockquote>
<p><i>Returns:</i> <code>*this == code.category() && 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 & rhs ) const;</code></p>
+<pre>bool operator==( const error_category & rhs ) const noexcept;</pre>
<blockquote>
<p><i>Returns:</i> <code>this == &rhs</code>.</p>
</blockquote>
-<p><code>bool operator!=( const error_category & rhs ) const;</code></p>
+<pre>bool operator!=( const error_category & rhs ) const noexcept;</pre>
<blockquote>
<p><i>Returns:</i> <code>this != &rhs</code>.</p>
</blockquote>
-<pre>bool operator<( const error_category & rhs ) const;</pre>
+<pre>bool operator<( const error_category & rhs ) const noexcept;</pre>
<blockquote>
- <p><i>Returns:</i> <code>std::less<const error_category*>()( this, &rhs )</code>.</p>
+ <p><i>Returns:</i> <code>std::less<const error_category*>()( this, &rhs
+ 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 & 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 & 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 @@
public:
// constructors:
- error_code();
- error_code( val, const error_category & cat );
+ error_code() noexcept;
+ error_code( val, const error_category & cat ) noexcept;
template <class <code>ErrorCodeEnum</code>>
- error_code(<code> ErrorCodeEnum</code> e );
+ error_code(<code> ErrorCodeEnum</code> e ) noexcept;
// modifiers:
- void assign( int val, const error_category & cat );
+ void assign( int val, const error_category & cat ) noexcept;
template<typename <code>ErrorCodeEnum</code>>
- error_code & operator=( <code>ErrorCodeEnum</code> val );;
- void clear();
+ error_code & operator=( <code>ErrorCodeEnum</code> val ) noexcept;
+ void clear() noexcept;
// observers:
- int value() const;
- cont error_category & category() const;
- error_condition default_error_condition() const;
+ int value() const noexcept;
+ cont error_category & category() const noexcept;
+ error_condition default_error_condition() const noexcept;
string message() const;
operator unspecified-bool-type() const;
@@ -467,71 +463,63 @@
</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 && cat_ == &system_category()</code>.</p>
- <p><i>Throws:</i> Nothing.</p>
</blockquote>
-<pre>error_code( int val, const error_category & cat );</pre>
+<pre>error_code( int val, const error_category & 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 && cat_ == &cat</code>.</p>
- <p><i>Throws:</i> Nothing.</p>
</blockquote>
<pre>template <class <code>ErrorCodeEnum</code>>
- 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<ErrorCodeEnum>::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 & cat );</pre>
+<pre>void assign( int val, const error_category & cat ) noexcept;</pre>
<blockquote>
<p><i>Postconditions:</i> <code>val_ == val && cat_ == &cat</code>.</p>
- <p><i>Throws:</i> Nothing.</p>
</blockquote>
<pre>template<typename <code>ErrorCodeEnum</code>>
- error_code & operator=( <code>ErrorCodeEnum</code> val );</pre>
+ error_code & 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<ErrorCodeEnum>::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 && 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 & category() const;</code></p>
+ </blockquote>
+<pre><code>const error_category & 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> <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> <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 @@
public:
// constructors:
- error_condition();
- error_condition( int val, const error_category & cat );
+ error_condition() noexcept;
+ error_condition( int val, const error_category & cat ) noexcept;
template <class ErrorConditionEnum>
- error_condition( errorConditionEnum val );
+ error_condition( errorConditionEnum val ) noexcept;
// modifiers:
- void assign( int val, const error_category & cat );
+ void assign( int val, const error_category & cat ) noexcept;
template<typename ErrorConditionEnum>
- error_condition & operator=( ErrorConditionEnum val );
- void clear();
+ error_condition & operator=( ErrorConditionEnum val ) noexcept;
+ void clear() noexcept;
// observers:
- int value() const;
- const error_category & category() const;
+ int value() const noexcept;
+ const error_category & 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 @@
</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_ == &generic_category()</code>.</p>
- <p><i>Throws:</i> Nothing.</p>
</blockquote>
-<pre>error_condition( int val, const error_category & cat );</pre>
+<pre>error_condition( int val, const error_category & 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_ == &cat</code>.</p>
- <p><i>Throws:</i> Nothing.</p>
</blockquote>
<pre>template <class ErrorConditionEnum>
- 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<ErrorConditionEnum>::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 & cat ); </pre>
+<pre>void assign( int val, const error_category & cat ) noexcept; </pre>
<blockquote>
<p><i>Postconditions:</i> <code>val_ == val and cat_ == &cat</code>. </p>
- <p><i>Throws:</i> Nothing.</p>
</blockquote>
<pre>template<typename ErrorConditionEnum>
- error_condition & operator=( ErrorConditionEnum e );</pre>
+ error_condition & 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<ErrorConditionEnum>::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 && category() == generic_category()</code></p>
+ <p><i>Postcondition:</i> <code>value() == 0 && 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 & category() const;</pre>
+<pre>const error_category & 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 @@
</blockquote>
</blockquote>
<h2><a name="Non-member-functions">Non-member functions</a></h2>
- <pre>bool operator==( const error_code & lhs, const error_code & rhs );</pre>
+ <pre>bool operator==( const error_code & lhs, const error_code & rhs ) noexcept;</pre>
<blockquote>
<p><i>Returns:</i> <code>lhs.category() == rhs.category() && lhs.value() ==
rhs.value()</code>.</p>
- <p><i>Throws: </i>Nothing.</p>
</blockquote>
-<pre>bool operator==( const error_code & code, const error_condition & condition );
-bool operator==( const error_condition & condition, const error_code & code );</pre>
+<pre>bool operator==( const error_code & code, const error_condition & condition ) noexcept;
+bool operator==( const error_condition & condition, const error_code & 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 & lhs, const error_condition & rhs );</pre>
+<pre>bool operator==( const error_condition & lhs, const error_condition & rhs ) noexcept;</pre>
<blockquote>
<p><i>Returns:</i> <code>lhs.category() == rhs.category() && lhs.value() ==
rhs.value()</code>.</p>
- <p><i>Throws: </i>Nothing.</p>
</blockquote>
-<pre>bool operator!=( const error_code & lhs, const error_code & rhs );</pre>
+<pre>bool operator!=( const error_code & lhs, const error_code & 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 & code, const error_condition & condition );
-bool operator!=( const error_condition & condition, const error_code & code );</pre>
+<pre>bool operator!=( const error_code & code, const error_condition & condition ) noexcept;
+bool operator!=( const error_condition & condition, const error_code & code ) noexcept;</pre>
<blockquote>
<p><i>Returns:</i><code> !( code == condition )</code>.</p>
- <p><i>Throws: </i>Nothing.</p>
</blockquote>
-<pre>bool operator!=( const error_condition & lhs, const error_condition & rhs );</pre>
+<pre>bool operator!=( const error_condition & lhs, const error_condition & 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 & lhs, const error_code & rhs );</pre>
+<pre>bool operator<( const error_code & lhs, const error_code & rhs ) noexcept;</pre>
<blockquote>
<p><i>Returns:</i> <code>lhs.category() < rhs.category()<br>
|| (lhs.category() == rhs.category() && lhs.value() < rhs.value())</code>.</p>
- <p><i>Throws: </i>Nothing.</p>
</blockquote>
-<pre>bool operator<( const error_condition & lhs, const error_condition & rhs );</pre>
+<pre>bool operator<( const error_condition & lhs, const error_condition & rhs ) noexcept;</pre>
<blockquote>
<p><i>Returns:</i> <code>lhs.category() < rhs.category()<br>
|| (lhs.category() == rhs.category() && lhs.value() < 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<int>( e ), generic_category())</code>.</p>
</blockquote>
@@ -840,10 +812,10 @@
<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>© Copyright Beman Dawes, 2006, 2007, 2008</p>
+<p>© 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>
Modified: branches/release/libs/system/src/error_code.cpp
==============================================================================
--- branches/release/libs/system/src/error_code.cpp (original)
+++ branches/release/libs/system/src/error_code.cpp 2013-03-24 16:20:29 EDT (Sun, 24 Mar 2013)
@@ -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 @@
# 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 @@
{
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 @@
}
}
std::string msg;
+# ifndef BOOST_NO_EXCEPTIONS
try
+# endif
{
msg = ( ( result == invalid_argument ) ? "Unknown error" : bp );
}
@@ -154,13 +160,18 @@
}
// 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 @@
} // 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 @@
// 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;
Modified: branches/release/libs/system/test/error_code_user_test.cpp
==============================================================================
--- branches/release/libs/system/test/error_code_user_test.cpp (original)
+++ branches/release/libs/system/test/error_code_user_test.cpp 2013-03-24 16:20:29 EDT (Sun, 24 Mar 2013)
@@ -75,7 +75,7 @@
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 @@
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 @@
};
- 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 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 @@
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 @@
}
};
- 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;
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk