===================================================================
@@ -101,7 +101,7 @@
public:
typedef typename _Pointer::type pointer;
typedef _Tp element_type;
- typedef _Dp deleter_type;
+ typedef _Dp deleter_type;
// Constructors.
unique_ptr()
@@ -432,6 +432,16 @@
const unique_ptr<_Up, _Ep>& __y)
{ return __x.get() == __y.get(); }
+ template<typename _Tp, typename _Dp>
+ inline bool
+ operator==(const unique_ptr<_Tp, _Dp>& __x, nullptr_t)
+ { return __x.get() == nullptr; }
+
+ template<typename _Tp, typename _Dp>
+ inline bool
+ operator==(nullptr_t, const unique_ptr<_Tp, _Dp>& __y)
+ { return nullptr == __y.get(); }
+
template<typename _Tp, typename _Dp,
typename _Up, typename _Ep>
inline bool
@@ -439,6 +449,16 @@
const unique_ptr<_Up, _Ep>& __y)
{ return !(__x.get() == __y.get()); }
+ template<typename _Tp, typename _Dp>
+ inline bool
+ operator!=(const unique_ptr<_Tp, _Dp>& __x, nullptr_t)
+ { return __x.get() != nullptr; }
+
+ template<typename _Tp, typename _Dp>
+ inline bool
+ operator!=(nullptr_t, const unique_ptr<_Tp, _Dp>& __y)
+ { return nullptr != __y.get(); }
+
template<typename _Tp, typename _Dp,
typename _Up, typename _Ep>
inline bool
===================================================================
@@ -851,12 +851,32 @@
const __shared_ptr<_Tp2, _Lp>& __b)
{ return __a.get() == __b.get(); }
+ template<typename _Tp, _Lock_policy _Lp>
+ inline bool
+ operator==(const __shared_ptr<_Tp, _Lp>& __a, nullptr_t)
+ { return __a.get() == nullptr; }
+
+ template<typename _Tp, _Lock_policy _Lp>
+ inline bool
+ operator==(nullptr_t, const __shared_ptr<_Tp, _Lp>& __b)
+ { return nullptr == __b.get(); }
+
template<typename _Tp1, typename _Tp2, _Lock_policy _Lp>
inline bool
operator!=(const __shared_ptr<_Tp1, _Lp>& __a,
const __shared_ptr<_Tp2, _Lp>& __b)
{ return __a.get() != __b.get(); }
+ template<typename _Tp, _Lock_policy _Lp>
+ inline bool
+ operator!=(const __shared_ptr<_Tp, _Lp>& __a, nullptr_t)
+ { return __a.get() != nullptr; }
+
+ template<typename _Tp, _Lock_policy _Lp>
+ inline bool
+ operator!=(nullptr_t, const __shared_ptr<_Tp, _Lp>& __b)
+ { return nullptr != __b.get(); }
+
template<typename _Tp1, typename _Tp2, _Lock_policy _Lp>
inline bool
operator<(const __shared_ptr<_Tp1, _Lp>& __a,
===================================================================
@@ -317,11 +317,31 @@
operator==(const shared_ptr<_Tp1>& __a, const shared_ptr<_Tp2>& __b)
{ return __a.get() == __b.get(); }
+ template<typename _Tp>
+ inline bool
+ operator==(const shared_ptr<_Tp>& __a, nullptr_t)
+ { return __a.get() == nullptr; }
+
+ template<typename _Tp>
+ inline bool
+ operator==(nullptr_t, const shared_ptr<_Tp>& __b)
+ { return nullptr == __b.get(); }
+
template<typename _Tp1, typename _Tp2>
inline bool
operator!=(const shared_ptr<_Tp1>& __a, const shared_ptr<_Tp2>& __b)
{ return __a.get() != __b.get(); }
+ template<typename _Tp>
+ inline bool
+ operator!=(const shared_ptr<_Tp>& __a, nullptr_t)
+ { return __a.get() != nullptr; }
+
+ template<typename _Tp>
+ inline bool
+ operator!=(nullptr_t, const shared_ptr<_Tp>& __b)
+ { return nullptr != __b.get(); }
+
template<typename _Tp1, typename _Tp2>
inline bool
operator<(const shared_ptr<_Tp1>& __a, const shared_ptr<_Tp2>& __b)
===================================================================
@@ -0,0 +1,37 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+
+// Copyright (C) 2010 Free Software Foundation
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 20.9.10 Class template unique_ptr [unique.ptr]
+
+#include <memory>
+
+// libstdc++/42925 (also see GB 99)
+void test01()
+{
+ std::unique_ptr<int> ptr;
+ if (ptr == 0)
+ { }
+ if (0 == ptr)
+ { }
+ if (ptr != 0)
+ { }
+ if (0 != ptr)
+ { }
+}
===================================================================
@@ -0,0 +1,37 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+
+// Copyright (C) 2010 Free Software Foundation
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 20.9.11.2 Class template shared_ptr [util.smartptr.shared]
+
+#include <memory>
+
+// libstdc++/42925 (also see GB 99)
+void test01()
+{
+ std::shared_ptr<int> ptr;
+ if (ptr == 0)
+ { }
+ if (0 == ptr)
+ { }
+ if (ptr != 0)
+ { }
+ if (0 != ptr)
+ { }
+}
===================================================================
@@ -41,9 +41,9 @@
return 0;
}
-// { dg-warning "note" "" { target *-*-* } 327 }
-// { dg-warning "note" "" { target *-*-* } 446 }
-// { dg-warning "note" "" { target *-*-* } 863 }
+// { dg-warning "note" "" { target *-*-* } 347 }
+// { dg-warning "note" "" { target *-*-* } 466 }
+// { dg-warning "note" "" { target *-*-* } 883 }
// { dg-warning "note" "" { target *-*-* } 580 }
// { dg-warning "note" "" { target *-*-* } 1027 }
// { dg-warning "note" "" { target *-*-* } 340 }