From 08ea984237321c015a03705612eca910a96643f8 Mon Sep 17 00:00:00 2001
From: Beman Dawes Returns: Throws: Nothing. Returns: if Throws: nothing. [Note: This conversion can be used in contexts where a Returns: The class Returns: Returns: If Throws: Nothing. [ Note: This conversion can be used in contexts where a Returns: string message() const;
-category().message( value())
.operator unspecified-bool-type() const;
+explicit operator bool() const noexcept;
-
value() != 0
, returns a value that will evaluate
-true
in a boolean context; otherwise, returns a value that will
-evaluate false
in a boolean context. The value type returned shall
-not be convertible to int
.bool
-is expected ( e.g., an if
condition ); however, implicit conversions
-( e.g., to int
) that can occur with bool
are not
-allowed, eliminating some sources of user error. One possible implementation
-choice for this type is pointer-to-member. --end note ]value() != 0
.Class
error_condition
error_condition
describes an object used to hold
@@ -560,10 +550,10 @@ implementation specific. --end note ]
-category().message( value() )
.operator unspecified-bool-type () const;
+explicit operator bool() const noexcept;
-
value() != 0
, returns a value that will
- evaluate true
in a boolean context; otherwise, returns a value
- that will evaluate false
. The return type shall not be
- convertible to int
. bool
- is expected ( e.g., an if condition ); however, implicit conversions ( e.g., to
- int
) that can occur with bool
are not allowed,
- eliminating some sources of user error. One possible implementation choice for
- this type is pointer to member. --end note ]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 +