Commit 115ac9ff by Jonathan Wakely Committed by Jonathan Wakely

PR79156 fix std::__enable_shared_from_this extension

	PR libstdc++/79156
	* include/bits/shared_ptr_base.h (__enable_shared_from_this_base):
	Fix return type.
	(__enable_shared_from_this): Declare __shared_ptr as a friend.
	* testsuite/ext/shared_ptr/1.cc: New test.

From-SVN: r244668
parent 27169e45
2017-01-19 Jonathan Wakely <jwakely@redhat.com>
PR libstdc++/79156
* include/bits/shared_ptr_base.h (__enable_shared_from_this_base):
Fix return type.
(__enable_shared_from_this): Declare __shared_ptr as a friend.
* testsuite/ext/shared_ptr/1.cc: New test.
PR libstdc++/64903
* include/bits/stl_algo.h (is_partioned): Don't retest the partition
point.
......
......@@ -1817,11 +1817,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_M_weak_assign(_Tp1* __p, const __shared_count<_Lp>& __n) const noexcept
{ _M_weak_this._M_assign(__p, __n); }
friend void
friend const __enable_shared_from_this*
__enable_shared_from_this_base(const __shared_count<_Lp>&,
const __enable_shared_from_this* __p)
{ return __p; }
template<typename, _Lock_policy>
friend class __shared_ptr;
mutable __weak_ptr<_Tp, _Lp> _M_weak_this;
};
......
// Copyright (C) 2017 Free Software Foundation, Inc.
//
// 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/>.
// { dg-do run { target c++11 } }
#include <memory>
#include <testsuite_hooks.h>
struct A : std::__enable_shared_from_this<A> { };
void
test01()
{
std::__shared_ptr<A> sp(new A);
auto sp2 = sp->shared_from_this();
VERIFY( (bool)sp2 );
static_assert( std::is_same<decltype(sp), decltype(sp2)>::value, "" );
}
int
main()
{
test01();
}
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