diff --git a/doc/reference.html b/doc/reference.html index 5671435..d2efbb2 100644 --- a/doc/reference.html +++ b/doc/reference.html @@ -458,7 +458,7 @@ 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 @@ -523,20 +523,10 @@
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 -truein a boolean context; otherwise, returns a value that will -evaluatefalsein 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., anifcondition ); however, implicit conversions -( e.g., toint) that can occur withboolare 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_conditionThe class error_condition describes an object used to hold
@@ -566,10 +556,10 @@
void clear() noexcept;
// observers:
- int value() const noexcept;
- const error_category & category() const noexcept;
- string message() const;
- operator unspecified-bool-type () const noexcept;
+ int value() const noexcept;
+ const error_category& category() const noexcept;
+ string message() const;
+ explicit operator bool() const noexcept;
private:
int val_; // exposition only
@@ -632,18 +622,9 @@
-Returns:
category().message( value() ).
operator unspecified-bool-type () const;-
-Returns: If
-value() != 0, returns a value that will - evaluatetruein 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 withboolare not allowed, - eliminating some sources of user error. One possible implementation choice for - this type is pointer to member. --end note ]explicit operator bool() const noexcept;++Returns:
value() != 0.
throwsobjectextern error_code throws;diff --git a/include/boost/system/error_code.hpp b/include/boost/system/error_code.hpp index b6ff6e4..6ec444f 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 024cb88..c6008fc 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -26,10 +26,10 @@ project : # command line : # input files : # requirements - static +always_show_run_output static ] [ run error_code_test.cpp - : : : shared : error_code_test_shared + : : : always_show_run_output shared : error_code_test_shared ] [ run error_code_user_test.cpp : : : static