mirror of git://gcc.gnu.org/git/gcc.git
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
This commit is contained in:
parent
7d2035fafe
commit
9a8e528cf1
|
|
@ -1,5 +1,10 @@
|
||||||
2016-08-04 Jonathan Wakely <jwakely@redhat.com>
|
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.
|
* include/std/functional (_Unwrap): Rename to __inv_unwrap.
|
||||||
(__invfwd): Adjust.
|
(__invfwd): Adjust.
|
||||||
(__invoke_impl): Remove unused template parameters.
|
(__invoke_impl): Remove unused template parameters.
|
||||||
|
|
|
||||||
|
|
@ -586,6 +586,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
shared_from_this() const
|
shared_from_this() const
|
||||||
{ return shared_ptr<const _Tp>(this->_M_weak_this); }
|
{ 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:
|
private:
|
||||||
template<typename _Tp1>
|
template<typename _Tp1>
|
||||||
void
|
void
|
||||||
|
|
|
||||||
|
|
@ -1472,7 +1472,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
void
|
void
|
||||||
_M_assign(_Tp* __ptr, const __shared_count<_Lp>& __refcount) noexcept
|
_M_assign(_Tp* __ptr, const __shared_count<_Lp>& __refcount) noexcept
|
||||||
{
|
{
|
||||||
#define __cpp_lib_enable_shared_from_this 201603
|
|
||||||
if (use_count() == 0)
|
if (use_count() == 0)
|
||||||
{
|
{
|
||||||
_M_ptr = __ptr;
|
_M_ptr = __ptr;
|
||||||
|
|
@ -1557,6 +1556,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
shared_from_this() const
|
shared_from_this() const
|
||||||
{ return __shared_ptr<const _Tp, _Lp>(this->_M_weak_this); }
|
{ 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:
|
private:
|
||||||
template<typename _Tp1>
|
template<typename _Tp1>
|
||||||
void
|
void
|
||||||
|
|
|
||||||
|
|
@ -15,15 +15,11 @@
|
||||||
// with this library; see the file COPYING3. If not see
|
// with this library; see the file COPYING3. If not see
|
||||||
// <http://www.gnu.org/licenses/>.
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
// { dg-options "-std=gnu++11" }
|
// { dg-do run { target c++11 } }
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <testsuite_hooks.h>
|
#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> { };
|
struct X : public std::enable_shared_from_this<X> { };
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue