2016-08-04 Jonathan Wakely <jwakely@redhat.com>
+ * testsuite/20_util/enable_shared_from_this/members/reinit.cc: Use
+ effective target not dg-options. Move check for feature-test macro to:
+ * testsuite/20_util/enable_shared_from_this/members/weak_from_this.cc:
+ New test.
+
* include/std/functional (_Unwrap): Rename to __inv_unwrap.
(__invfwd): Adjust.
(__invoke_impl): Remove unused template parameters.
shared_from_this() const
{ return shared_ptr<const _Tp>(this->_M_weak_this); }
+#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11
+#define __cpp_lib_enable_shared_from_this 201603
+ weak_ptr<_Tp>
+ weak_from_this()
+ { return this->_M_weak_this; }
+
+ weak_ptr<const _Tp>
+ weak_from_this() const
+ { return this->_M_weak_this; }
+#endif
+
private:
template<typename _Tp1>
void
void
_M_assign(_Tp* __ptr, const __shared_count<_Lp>& __refcount) noexcept
{
-#define __cpp_lib_enable_shared_from_this 201603
if (use_count() == 0)
{
_M_ptr = __ptr;
shared_from_this() const
{ return __shared_ptr<const _Tp, _Lp>(this->_M_weak_this); }
+#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11
+ __weak_ptr<_Tp, _Lp>
+ weak_from_this()
+ { return this->_M_weak_this; }
+
+ __weak_ptr<const _Tp, _Lp>
+ weak_from_this() const
+ { return this->_M_weak_this; }
+#endif
+
private:
template<typename _Tp1>
void
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// { dg-options "-std=gnu++11" }
+// { dg-do run { target c++11 } }
#include <memory>
#include <testsuite_hooks.h>
-#if __cpp_lib_enable_shared_from_this < 201603
-# error "__cpp_lib_enable_shared_from_this < 201603"
-#endif
-
struct X : public std::enable_shared_from_this<X> { };
bool