diff --git a/doc/reference.html b/doc/reference.html index 24efd4e..bf54540 100644 --- a/doc/reference.html +++ b/doc/reference.html @@ -452,7 +452,7 @@ error_code synopsis cont error_category & category() const noexcept; error_condition default_error_condition() const noexcept; string message() const; - operator unspecified-bool-type() const; + explicit operator bool() const noexcept; private: int val_; // exposition only @@ -517,20 +517,10 @@ error_code observers
string message() const;
-Returns:
-category().message( value())
.Throws: Nothing.
operator unspecified-bool-type() const;+
explicit operator bool() const noexcept;
-Returns: if
-value() != 0
, returns a value that will evaluate -true
in a boolean context; otherwise, returns a value that will -evaluatefalse
in a boolean context. The value type returned shall -not be convertible toint
.Throws: nothing.
-[Note: This conversion can be used in contexts where a
+bool
-is expected ( e.g., anif
condition ); however, implicit conversions -( e.g., toint
) that can occur withbool
are not -allowed, eliminating some sources of user error. One possible implementation -choice for this type is pointer-to-member. --end note ]Returns:
value() != 0
.
error_condition
The class error_condition
describes an object used to hold
@@ -560,10 +550,10 @@ implementation specific. --end note ]
-Returns:
category().message( value() )
.
operator unspecified-bool-type () const;+
explicit operator bool() const noexcept;
-Returns: If
-value() != 0
, returns a value that will - evaluatetrue
in a boolean context; otherwise, returns a value - that will evaluatefalse
. The return type shall not be - convertible toint
.Throws: Nothing.
-[ Note: This conversion can be used in contexts where a
+bool
- is expected ( e.g., an if condition ); however, implicit conversions ( e.g., to -int
) that can occur withbool
are not allowed, - eliminating some sources of user error. One possible implementation choice for - this type is pointer to member. --end note ]Returns:
value() != 0
.
throws
objectextern error_code throws;@@ -812,7 +793,7 @@ application program interfaces.
Revised -February 27, 2013 +February 28, 2013
© Copyright Beman Dawes, 2006, 2007, 2008, 2013
diff --git a/include/boost/system/error_code.hpp b/include/boost/system/error_code.hpp index 3e7689c..812e779 100644 --- a/include/boost/system/error_code.hpp +++ b/include/boost/system/error_code.hpp @@ -270,6 +270,12 @@ namespace boost const error_category & category() const BOOST_SYSTEM_NOEXCEPT { return *m_cat; } std::string message() const { return m_cat->message(value()); } +# ifndef BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS + explicit operator bool() const BOOST_SYSTEM_NOEXCEPT + { + return m_val != 0; + } +# else typedef void (*unspecified_bool_type)(); static void unspecified_bool_true() {} @@ -282,6 +288,7 @@ namespace boost { return m_val == 0; } +# endif // relationals: // the more symmetrical non-member syntax allows enum @@ -357,6 +364,12 @@ namespace boost 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()); } +# ifndef BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS + explicit operator bool() const BOOST_SYSTEM_NOEXCEPT + { + return m_val != 0; + } +# else typedef void (*unspecified_bool_type)(); static void unspecified_bool_true() {} @@ -369,6 +382,7 @@ namespace boost { return m_val == 0; } +# endif // relationals: inline friend bool operator==( const error_code & lhs, diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 1ab7442..1785f55 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -25,10 +25,10 @@ project : # command line : # input files : # requirements - static +