From c7fdbdcdbd9f2ea3393ff6b3714394fa3922ab09 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Wed, 3 Aug 2016 20:10:06 +0100 Subject: [PATCH] Define feature-test macro for std::enable_shared_from_this * include/bits/shared_ptr_base.h (__cpp_lib_enable_shared_from_this): Define feature-test macro. * testsuite/20_util/enable_shared_from_this/members/reinit.cc: Test for the macro. From-SVN: r239094 --- libstdc++-v3/ChangeLog | 5 +++++ libstdc++-v3/include/bits/shared_ptr_base.h | 1 + .../20_util/enable_shared_from_this/members/reinit.cc | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 2c23c4baf68..d1162310bf6 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,10 @@ 2016-08-03 Jonathan Wakely + * include/bits/shared_ptr_base.h (__cpp_lib_enable_shared_from_this): + Define feature-test macro. + * testsuite/20_util/enable_shared_from_this/members/reinit.cc: Test + for the macro. + * include/bits/shared_ptr.h (shared_ptr::weak_type): Define. * include/bits/shared_ptr_base.h (__shared_ptr::weak_type): Define. * testsuite/20_util/shared_ptr/cons/43820_neg.cc: Adjust dg-error. diff --git a/libstdc++-v3/include/bits/shared_ptr_base.h b/libstdc++-v3/include/bits/shared_ptr_base.h index 93ce9013f30..2698ba453a6 100644 --- a/libstdc++-v3/include/bits/shared_ptr_base.h +++ b/libstdc++-v3/include/bits/shared_ptr_base.h @@ -1472,6 +1472,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION 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; diff --git a/libstdc++-v3/testsuite/20_util/enable_shared_from_this/members/reinit.cc b/libstdc++-v3/testsuite/20_util/enable_shared_from_this/members/reinit.cc index 4ce23bc8479..1cf914805a4 100644 --- a/libstdc++-v3/testsuite/20_util/enable_shared_from_this/members/reinit.cc +++ b/libstdc++-v3/testsuite/20_util/enable_shared_from_this/members/reinit.cc @@ -20,6 +20,10 @@ #include #include +#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 { }; bool -- 2.30.2