aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libstdc++-v3/ChangeLog24
-rw-r--r--libstdc++-v3/include/bits/shared_ptr.h9
-rw-r--r--libstdc++-v3/include/bits/unique_ptr.h10
-rw-r--r--libstdc++-v3/include/std/istream9
-rw-r--r--libstdc++-v3/include/std/mutex2
-rw-r--r--libstdc++-v3/include/std/ostream5
-rw-r--r--libstdc++-v3/include/std/system_error22
-rw-r--r--libstdc++-v3/include/tr1_impl/functional7
-rw-r--r--libstdc++-v3/testsuite/19_diagnostics/error_code/operators/bool.cc4
-rw-r--r--libstdc++-v3/testsuite/19_diagnostics/error_code/operators/bool_neg.cc2
-rw-r--r--libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/bool.cc4
-rw-r--r--libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/bool_neg.cc2
-rw-r--r--libstdc++-v3/testsuite/20_util/shared_ptr/observers/bool_conv.cc16
-rw-r--r--libstdc++-v3/testsuite/20_util/unique_ptr/assign/assign_neg.cc6
-rw-r--r--libstdc++-v3/testsuite/20_util/unique_ptr/modifiers/reset_neg.cc2
15 files changed, 67 insertions, 57 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 80460d3..d0d5d66 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,21 @@
+2009-05-20 Benjamin Kosnik <bkoz@redhat.com>
+
+ * include/tr1_impl/functional (function): Use explicit operator bool.
+ * include/bits/shared_ptr.h (__shared_ptr): Same.
+ * include/bits/unique_ptr.h (unique_ptr): Same.
+ * include/std/mutex (unique_lock): Same.
+ * include/std/system_error (error_code): Same.
+ (error_condition): Same.
+ * include/std/ostream (sentry): Same.
+ * include/std/istream (sentry): Same.
+ * testsuite/19_diagnostics/error_condition/operators/bool.cc: Adjust.
+ * testsuite/19_diagnostics/error_condition/operators/bool_neg.cc: Same.
+ * testsuite/19_diagnostics/error_code/operators/bool.cc: Same.
+ * testsuite/19_diagnostics/error_code/operators/bool_neg.cc: Same.
+ * testsuite/20_util/unique_ptr/modifiers/reset_neg.cc: Same.
+ * testsuite/20_util/unique_ptr/assign/assign_neg.cc: Same.
+ * testsuite/20_util/shared_ptr/observers/bool_conv.cc: Same.
+
2009-05-19 Benjamin Kosnik <bkoz@redhat.com>
* testsuite/23_containers/list/14340.cc: Abstract list type.
@@ -182,7 +200,7 @@
* testsuite/26_numerics/random/piecewise_linear_distribution/cons/
initlist_fun.cc: Likewise
* testsuite/26_numerics/random/piecewise_linear_distribution/cons/
- num_xbound_fun.cc: Likewise
+ num_xbound_fun.cc: Likewise
2009-05-14 Paolo Carlini <paolo.carlini@oracle.com>
@@ -200,7 +218,7 @@
2009-05-14 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/random.tcc (cauchy_distribution<>::
- operator()(_UniformRandomNumberGenerator&, const param_type&)):
+ operator()(_UniformRandomNumberGenerator&, const param_type&)):
Avoid M_PI, a glibc extension.
2009-05-13 Ben Elliston <bje@au.ibm.com>
@@ -215,7 +233,7 @@
2009-05-12 Edward Smith-Rowland <3dw4rd@verizon.net>
- * doc/xml/manual/status_cxx200x.xml: Note missing constexpr for
+ * doc/xml/manual/status_cxx200x.xml: Note missing constexpr for
random number engines, complex, bitset, array, time utilities, and
char_traits.
diff --git a/libstdc++-v3/include/bits/shared_ptr.h b/libstdc++-v3/include/bits/shared_ptr.h
index a378ae0..c7a45f3 100644
--- a/libstdc++-v3/include/bits/shared_ptr.h
+++ b/libstdc++-v3/include/bits/shared_ptr.h
@@ -816,13 +816,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
get() const // never throws
{ return _M_ptr; }
- // Implicit conversion to "bool"
- private:
- typedef _Tp* __shared_ptr::*__unspecified_bool_type;
-
- public:
- operator __unspecified_bool_type() const // never throws
- { return _M_ptr == 0 ? 0 : &__shared_ptr::_M_ptr; }
+ explicit operator bool() const // never throws
+ { return _M_ptr == 0 ? false : true; }
bool
unique() const // never throws
diff --git a/libstdc++-v3/include/bits/unique_ptr.h b/libstdc++-v3/include/bits/unique_ptr.h
index c1185f2..7c08c81 100644
--- a/libstdc++-v3/include/bits/unique_ptr.h
+++ b/libstdc++-v3/include/bits/unique_ptr.h
@@ -85,7 +85,6 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
class unique_ptr
{
typedef std::tuple<_Tp*, _Tp_Deleter> __tuple_type;
- typedef __tuple_type unique_ptr::* __unspecified_bool_type;
typedef _Tp* unique_ptr::* __unspecified_pointer_type;
public:
@@ -181,8 +180,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
get_deleter() const
{ return std::get<1>(_M_t); }
- operator __unspecified_bool_type () const
- { return get() == 0 ? 0 : &unique_ptr::_M_t; }
+ explicit operator bool() const
+ { return get() == 0 ? false : true; }
// Modifiers.
pointer
@@ -233,7 +232,6 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
class unique_ptr<_Tp[], _Tp_Deleter>
{
typedef std::tuple<_Tp*, _Tp_Deleter> __tuple_type;
- typedef __tuple_type unique_ptr::* __unspecified_bool_type;
typedef _Tp* unique_ptr::* __unspecified_pointer_type;
public:
@@ -323,8 +321,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
get_deleter() const
{ return std::get<1>(_M_t); }
- operator __unspecified_bool_type () const
- { return get() == 0 ? 0 : &unique_ptr::_M_t; }
+ explicit operator bool() const
+ { return get() == 0 ? false : true; }
// Modifiers.
pointer
diff --git a/libstdc++-v3/include/std/istream b/libstdc++-v3/include/std/istream
index 521be7f..1979a51 100644
--- a/libstdc++-v3/include/std/istream
+++ b/libstdc++-v3/include/std/istream
@@ -631,6 +631,9 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
template<typename _CharT, typename _Traits>
class basic_istream<_CharT, _Traits>::sentry
{
+ // Data Members.
+ bool _M_ok;
+
public:
/// Easy access to dependant types.
typedef _Traits traits_type;
@@ -670,11 +673,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
* For ease of use, sentries may be converted to booleans. The
* return value is that of the sentry state (true == okay).
*/
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ explicit
+#endif
operator bool() const
{ return _M_ok; }
-
- private:
- bool _M_ok;
};
// [27.6.1.2.3] character extraction templates
diff --git a/libstdc++-v3/include/std/mutex b/libstdc++-v3/include/std/mutex
index 75595a9..b3a0438 100644
--- a/libstdc++-v3/include/std/mutex
+++ b/libstdc++-v3/include/std/mutex
@@ -574,7 +574,7 @@ namespace std
owns_lock() const
{ return _M_owns; }
- /* explicit */ operator bool () const
+ explicit operator bool() const
{ return owns_lock(); }
mutex_type*
diff --git a/libstdc++-v3/include/std/ostream b/libstdc++-v3/include/std/ostream
index c49b36f..b9ea4a8 100644
--- a/libstdc++-v3/include/std/ostream
+++ b/libstdc++-v3/include/std/ostream
@@ -376,7 +376,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
template <typename _CharT, typename _Traits>
class basic_ostream<_CharT, _Traits>::sentry
{
- // Data Members:
+ // Data Members.
bool _M_ok;
basic_ostream<_CharT, _Traits>& _M_os;
@@ -420,6 +420,9 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
* For ease of use, sentries may be converted to booleans. The
* return value is that of the sentry state (true == okay).
*/
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ explicit
+#endif
operator bool() const
{ return _M_ok; }
};
diff --git a/libstdc++-v3/include/std/system_error b/libstdc++-v3/include/std/system_error
index b9902a1..7f462a2 100644
--- a/libstdc++-v3/include/std/system_error
+++ b/libstdc++-v3/include/std/system_error
@@ -152,15 +152,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
message() const
{ return category().message(value()); }
- // Safe bool idiom.
- // explicit operator bool() const throw()
- // { return _M_value != 0; }
- typedef void (*__bool_type)();
-
- static void __not_bool_type() { }
-
- operator __bool_type() const
- { return _M_value != 0 ? &__not_bool_type : false; }
+ explicit operator bool() const
+ { return _M_value != 0 ? true : false; }
// DR 804.
private:
@@ -233,15 +226,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
message() const
{ return category().message(value()); }
- // Safe bool idiom.
- // explicit operator bool() const throw()
- // { return _M_value != 0; }
- typedef void (*__bool_type)();
-
- static void __not_bool_type() { }
-
- operator __bool_type() const
- { return _M_value != 0 ? &__not_bool_type : false; }
+ explicit operator bool() const
+ { return _M_value != 0 ? true : false; }
// DR 804.
private:
diff --git a/libstdc++-v3/include/tr1_impl/functional b/libstdc++-v3/include/tr1_impl/functional
index 7e6eaeb..75a6fdf 100644
--- a/libstdc++-v3/include/tr1_impl/functional
+++ b/libstdc++-v3/include/tr1_impl/functional
@@ -1761,6 +1761,7 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1
: public _Maybe_unary_or_binary_function<_Res, _ArgTypes...>,
private _Function_base
{
+#ifndef __GXX_EXPERIMENTAL_CXX0X__
/// This class is used to implement the safe_bool idiom.
struct _Hidden_type
{
@@ -1769,6 +1770,7 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1
/// This typedef is used to implement the safe_bool idiom.
typedef _Hidden_type* _Hidden_type::* _Safe_bool;
+#endif
typedef _Res _Signature_type(_ArgTypes...);
@@ -1918,6 +1920,10 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1
*
* This function will not throw an exception.
*/
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ explicit operator bool() const
+ { return !_M_empty(); }
+#else
operator _Safe_bool() const
{
if (_M_empty())
@@ -1925,6 +1931,7 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1
else
return &_Hidden_type::_M_bool;
}
+#endif
// [3.7.2.4] function invocation
diff --git a/libstdc++-v3/testsuite/19_diagnostics/error_code/operators/bool.cc b/libstdc++-v3/testsuite/19_diagnostics/error_code/operators/bool.cc
index 5153603..2562b8d 100644
--- a/libstdc++-v3/testsuite/19_diagnostics/error_code/operators/bool.cc
+++ b/libstdc++-v3/testsuite/19_diagnostics/error_code/operators/bool.cc
@@ -28,14 +28,14 @@ int main()
// 1
std::error_code e1;
- if (e1)
+ if (static_cast<bool>(e1))
{
VERIFY( false );
}
// 2
std::error_code e2(std::make_error_code(std::errc::operation_not_supported));
- if (e2)
+ if (static_cast<bool>(e2))
{
VERIFY( true );
}
diff --git a/libstdc++-v3/testsuite/19_diagnostics/error_code/operators/bool_neg.cc b/libstdc++-v3/testsuite/19_diagnostics/error_code/operators/bool_neg.cc
index fed1cdc..554b59f 100644
--- a/libstdc++-v3/testsuite/19_diagnostics/error_code/operators/bool_neg.cc
+++ b/libstdc++-v3/testsuite/19_diagnostics/error_code/operators/bool_neg.cc
@@ -30,4 +30,4 @@ int main()
return i;
}
-// { dg-error "invalid conversion" "" { target *-*-* } 28 }
+// { dg-error "could not convert" "" { target *-*-* } 28 }
diff --git a/libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/bool.cc b/libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/bool.cc
index 17a9553..62490fd 100644
--- a/libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/bool.cc
+++ b/libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/bool.cc
@@ -27,14 +27,14 @@ void test01()
// 1
std::error_condition e1;
- if (e1)
+ if (static_cast<bool>(e1))
{
VERIFY( false );
}
// 2
std::error_condition e2(std::errc::operation_not_supported);
- if (e2)
+ if (static_cast<bool>(e2))
{
VERIFY( true );
}
diff --git a/libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/bool_neg.cc b/libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/bool_neg.cc
index 5e8ed96..776179f 100644
--- a/libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/bool_neg.cc
+++ b/libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/bool_neg.cc
@@ -29,4 +29,4 @@ int test01()
return i;
}
-// { dg-error "invalid conversion" "" { target *-*-* } 27 }
+// { dg-error "could not convert" "" { target *-*-* } 27 }
diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/observers/bool_conv.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/observers/bool_conv.cc
index f57284f..dc2d533 100644
--- a/libstdc++-v3/testsuite/20_util/shared_ptr/observers/bool_conv.cc
+++ b/libstdc++-v3/testsuite/20_util/shared_ptr/observers/bool_conv.cc
@@ -33,9 +33,9 @@ test01()
bool test __attribute__((unused)) = true;
const std::shared_ptr<A> p1;
- VERIFY( p1 == false );
+ VERIFY( static_cast<bool>(p1) == false );
const std::shared_ptr<A> p2(p1);
- VERIFY( p2 == false );
+ VERIFY( static_cast<bool>(p2) == false );
}
void
@@ -44,12 +44,12 @@ test02()
bool test __attribute__((unused)) = true;
std::shared_ptr<A> p1(new A);
- VERIFY( p1 );
+ VERIFY( static_cast<bool>(p1) );
std::shared_ptr<A> p2(p1);
- VERIFY( p2 );
+ VERIFY( static_cast<bool>(p2) );
p1.reset();
- VERIFY( !p1 );
- VERIFY( p2 );
+ VERIFY( !static_cast<bool>(p1) );
+ VERIFY( static_cast<bool>(p2) );
}
void
@@ -60,8 +60,8 @@ test03()
std::shared_ptr<A> p1(new A);
std::shared_ptr<A> p2(p1);
p2.reset(new A);
- VERIFY( p1 );
- VERIFY( p2 );
+ VERIFY( static_cast<bool>(p1) );
+ VERIFY( static_cast<bool>(p2) );
}
diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/assign/assign_neg.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/assign/assign_neg.cc
index af4641b..f0236eb 100644
--- a/libstdc++-v3/testsuite/20_util/unique_ptr/assign/assign_neg.cc
+++ b/libstdc++-v3/testsuite/20_util/unique_ptr/assign/assign_neg.cc
@@ -52,7 +52,7 @@ test03()
// { dg-error "used here" "" { target *-*-* } 42 }
// { dg-error "no matching" "" { target *-*-* } 48 }
// { dg-error "used here" "" { target *-*-* } 49 }
-// { dg-error "candidates are" "" { target *-*-* } 214 }
-// { dg-error "deleted function" "" { target *-*-* } 214 }
-// { dg-error "deleted function" "" { target *-*-* } 360 }
+// { dg-error "candidates are" "" { target *-*-* } 213 }
+// { dg-error "deleted function" "" { target *-*-* } 213 }
+// { dg-error "deleted function" "" { target *-*-* } 358 }
// { dg-excess-errors "note" }
diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/modifiers/reset_neg.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/modifiers/reset_neg.cc
index fbf3e77..ae3d3946 100644
--- a/libstdc++-v3/testsuite/20_util/unique_ptr/modifiers/reset_neg.cc
+++ b/libstdc++-v3/testsuite/20_util/unique_ptr/modifiers/reset_neg.cc
@@ -36,4 +36,4 @@ void test01()
}
// { dg-error "used here" "" { target *-*-* } 35 }
-// { dg-error "deleted function" "" { target *-*-* } 350 }
+// { dg-error "deleted function" "" { target *-*-* } 348 }