Commit 9a8e528c by Jonathan Wakely Committed by Jonathan Wakely

Define std::enable_shared_from_this::weak_from_this

	* 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.

From-SVN: r239121
parent 7d2035fa
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.
......
......@@ -586,6 +586,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
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
......
......@@ -1472,7 +1472,6 @@ _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;
......@@ -1557,6 +1556,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
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
......
......@@ -15,15 +15,11 @@
// 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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment