|
Boost-Commit : |
From: pdimov_at_[hidden]
Date: 2008-03-24 12:00:28
Author: pdimov
Date: 2008-03-24 12:00:28 EDT (Mon, 24 Mar 2008)
New Revision: 43829
URL: http://svn.boost.org/trac/boost/changeset/43829
Log:
New enable_shared_from_this tests, fix.
Text files modified:
trunk/boost/enable_shared_from_this.hpp | 2 +-
trunk/libs/smart_ptr/test/esft_regtest.cpp | 38 +++++++++++++++++++++++++++++++++++++-
2 files changed, 38 insertions(+), 2 deletions(-)
Modified: trunk/boost/enable_shared_from_this.hpp
==============================================================================
--- trunk/boost/enable_shared_from_this.hpp (original)
+++ trunk/boost/enable_shared_from_this.hpp 2008-03-24 12:00:28 EDT (Mon, 24 Mar 2008)
@@ -95,7 +95,7 @@
{
init_internal_shared_once();
get_deleter<detail::sp_deleter_wrapper>(_internal_shared_this)->set_deleter(owner);
- owner = dynamic_pointer_cast<U>(_internal_shared_this);
+ owner.reset( _internal_shared_this, owner.get() );
_internal_shared_this.reset();
_owned = true;
}
Modified: trunk/libs/smart_ptr/test/esft_regtest.cpp
==============================================================================
--- trunk/libs/smart_ptr/test/esft_regtest.cpp (original)
+++ trunk/libs/smart_ptr/test/esft_regtest.cpp 2008-03-24 12:00:28 EDT (Mon, 24 Mar 2008)
@@ -16,6 +16,7 @@
#include <boost/weak_ptr.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <memory>
+#include <string>
class X: public boost::enable_shared_from_this< X >
{
@@ -65,7 +66,7 @@
int X::instances = 0;
-int main()
+void test()
{
BOOST_TEST( X::instances == 0 );
@@ -131,6 +132,41 @@
}
BOOST_TEST( X::instances == 0 );
+}
+
+struct V: public boost::enable_shared_from_this<V>
+{
+ virtual ~V() {}
+ std::string m_;
+};
+
+struct V2
+{
+ virtual ~V2() {}
+ std::string m2_;
+};
+
+struct W: V2, V
+{
+};
+
+void test2()
+{
+ boost::shared_ptr<W> p( new W );
+}
+
+void test3()
+{
+ V * p = new W;
+ boost::shared_ptr<void> pv( p );
+ BOOST_TEST( pv.get() == p );
+}
+
+int main()
+{
+ test();
+ test2();
+ test3();
return boost::report_errors();
}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk