From fb559afd0dc540774a41fda1c72cc64addebe075 Mon Sep 17 00:00:00 2001 From: Robert Ramey Date: Wed, 19 Feb 2014 13:11:33 -0800 Subject: [PATCH 1/5] fix various trac items --- .../boost/archive/basic_text_iprimitive.hpp | 4 +- .../archive/impl/basic_binary_iarchive.ipp | 7 + .../archive/impl/basic_text_iprimitive.ipp | 8 +- .../boost/archive/impl/xml_wiarchive_impl.ipp | 2 +- .../archive/polymorphic_text_woarchive.hpp | 2 +- .../boost/serialization/shared_ptr_helper.hpp | 5 +- include/boost/serialization/unique_ptr.hpp | 1 + test/test_enable_shared_from_this.cpp | 195 ++++++++++++++++++ test/test_unique_ptr.cpp | 10 +- 9 files changed, 218 insertions(+), 16 deletions(-) create mode 100644 test/test_enable_shared_from_this.cpp diff --git a/include/boost/archive/basic_text_iprimitive.hpp b/include/boost/archive/basic_text_iprimitive.hpp index 8c04d2d6..bd0e2301 100644 --- a/include/boost/archive/basic_text_iprimitive.hpp +++ b/include/boost/archive/basic_text_iprimitive.hpp @@ -86,10 +86,8 @@ public: template void load(T & t) { - if(! is.fail()){ - is >> t; + if(is >> t) return; - } boost::serialization::throw_exception( archive_exception(archive_exception::input_stream_error) ); diff --git a/include/boost/archive/impl/basic_binary_iarchive.ipp b/include/boost/archive/impl/basic_binary_iarchive.ipp index e555328f..8a718568 100644 --- a/include/boost/archive/impl/basic_binary_iarchive.ipp +++ b/include/boost/archive/impl/basic_binary_iarchive.ipp @@ -51,6 +51,8 @@ BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) basic_binary_iarchive::init(){ // read signature in an archive version independent manner std::string file_signature; + + #if 0 // commented out since it interfers with derivation try { std::size_t l; this->This()->load(l); @@ -69,6 +71,11 @@ basic_binary_iarchive::init(){ // will cause invalid_signature archive exception to be thrown below file_signature = ""; } + #else + // https://svn.boost.org/trac/boost/ticket/7301 + * this->This() >> file_signature; + #endif + if(file_signature != BOOST_ARCHIVE_SIGNATURE()) boost::serialization::throw_exception( archive_exception(archive_exception::invalid_signature) diff --git a/include/boost/archive/impl/basic_text_iprimitive.ipp b/include/boost/archive/impl/basic_text_iprimitive.ipp index 16378b84..ce9ad325 100644 --- a/include/boost/archive/impl/basic_text_iprimitive.ipp +++ b/include/boost/archive/impl/basic_text_iprimitive.ipp @@ -30,10 +30,10 @@ namespace std{ #include #include -namespace boost { +namespace boost { namespace archive { -namespace { +namespace detail { template bool is_whitespace(CharType c); @@ -48,7 +48,7 @@ namespace { return 0 != std::iswspace(t); } #endif -} +} // detail // translate base64 text into binary and copy into buffer // until buffer is full. @@ -106,7 +106,7 @@ basic_text_iprimitive::load_binary( r = is.get(); if(is.eof()) break; - if(is_whitespace(static_cast(r))) + if(detail::is_whitespace(static_cast(r))) break; } } diff --git a/include/boost/archive/impl/xml_wiarchive_impl.ipp b/include/boost/archive/impl/xml_wiarchive_impl.ipp index 07b34a4d..b2c7cced 100644 --- a/include/boost/archive/impl/xml_wiarchive_impl.ipp +++ b/include/boost/archive/impl/xml_wiarchive_impl.ipp @@ -1,5 +1,5 @@ /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 -// xml_wiprimitive.cpp: +// xml_wiarchive_impl.ipp: // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . // Distributed under the Boost Software License, Version 1.0. (See diff --git a/include/boost/archive/polymorphic_text_woarchive.hpp b/include/boost/archive/polymorphic_text_woarchive.hpp index 1013b488..295625d1 100644 --- a/include/boost/archive/polymorphic_text_woarchive.hpp +++ b/include/boost/archive/polymorphic_text_woarchive.hpp @@ -28,7 +28,7 @@ namespace boost { namespace archive { typedef detail::polymorphic_oarchive_route< - text_woarchive_impl + text_woarchive_impl > polymorphic_text_woarchive; } // namespace archive diff --git a/include/boost/serialization/shared_ptr_helper.hpp b/include/boost/serialization/shared_ptr_helper.hpp index 808ba2ba..276c13a4 100644 --- a/include/boost/serialization/shared_ptr_helper.hpp +++ b/include/boost/serialization/shared_ptr_helper.hpp @@ -27,9 +27,10 @@ #include #include -#include +//#include +#include #include - +#include #include #include diff --git a/include/boost/serialization/unique_ptr.hpp b/include/boost/serialization/unique_ptr.hpp index dc22a770..ac615b9d 100644 --- a/include/boost/serialization/unique_ptr.hpp +++ b/include/boost/serialization/unique_ptr.hpp @@ -15,6 +15,7 @@ // http://www.boost.org/LICENSE_1_0.txt) // See http://www.boost.org for updates, documentation, and revision history. +#include #include #include diff --git a/test/test_enable_shared_from_this.cpp b/test/test_enable_shared_from_this.cpp new file mode 100644 index 00000000..9003aee1 --- /dev/null +++ b/test/test_enable_shared_from_this.cpp @@ -0,0 +1,195 @@ +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// test_enable_shared_from_this.cpp + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// This demonstrates a problem with boost::serialization and boost::enable_shared_from_this. +// (boost version 1.53) +// See boost TRAC ticket #9567 +// +// Given the following class structure: +// Base is a simple class +// Derived inherits from Base +// Derived also inherits from boost::enable_shared_from_this +// Base and Derived implement boost::serialization +// +// When deserializing an instance of Derived into a vector of boost::shared_ptr: +// Base and Derived members are reconstructed correctly. +// Derived::shared_from_this() works as expected. +// +// But when deserializing an instance of Derived into a vector of boost::shared_ptr: +// Base and Derived members are still reconstructed correctly. +// Derived::shared_from_this() throws a bad_weak_ptr exception. +// This is because enable_shared_from_this::weak_ptr is NOT reconstructed - It is zero. + +#include + +#include +#include + +#include +#include +#include +#include + +#include "test_tools.hpp" + +#include + +namespace boost { +namespace serialization { + +struct enable_shared_from_this_helper { + std::set > m_esfth; + void record(boost::shared_ptr sp){ + m_esfth.insert(sp); + } +}; + +template +void serialize( + Archive & ar, + boost::enable_shared_from_this & t, + const unsigned int file_version +){ + enable_shared_from_this_helper & h = + ar.template get_helper< + enable_shared_from_this_helper + >(); + + shared_ptr sp = t.shared_from_this(); + h.record(sp); +} + +} // serialization +} // boost + +class Base { + friend class boost::serialization::access; + + template + void serialize(Archive & ar, const unsigned int version) + { + ar & BOOST_SERIALIZATION_NVP(m_base); + } +protected: + Base() {} + virtual ~Base() {} // "virtual" forces RTTI, to enable serialization of Derived from Base pointer +public: + int m_base; +}; + +class Derived : public Base, public boost::enable_shared_from_this { + friend class boost::serialization::access; + + template + void serialize(Archive & ar, const unsigned int version) + { + ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Base); + ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( + boost::enable_shared_from_this + ); + ar & BOOST_SERIALIZATION_NVP(m_derived); + } +public: + boost::shared_ptr SharedPtr() { return shared_from_this(); } + int m_derived; + Derived() {} + ~Derived() {} +}; +// The following is required to enable serialization from Base pointer +BOOST_CLASS_EXPORT(Derived) + +// This test passes +void test_passes(){ + std::stringstream ss; + { + boost::shared_ptr d(new Derived()); + d->m_base = 1; + d->m_derived = 2; + + // Get a raw pointer to Derived + Derived* raw_d = d.get(); + + // Verify base and derived members + BOOST_CHECK(raw_d->m_base==1); + BOOST_CHECK(raw_d->m_derived==2); + + // verify shared_from_this + BOOST_CHECK(d == raw_d->SharedPtr()); + + boost::archive::text_oarchive oa(ss); + oa & BOOST_SERIALIZATION_NVP(d); + } + { + // Deserialize it back into a vector of shared_ptr + boost::shared_ptr d; + ss.seekg(0); + boost::archive::text_iarchive ia(ss); + ia & BOOST_SERIALIZATION_NVP(d); + + // Get a raw pointer to Derived + Derived* raw_d = d.get(); + + // Verify base and derived members + BOOST_CHECK(raw_d->m_base==1); + BOOST_CHECK(raw_d->m_derived==2); + + // verify shared_from_this + BOOST_CHECK(d == raw_d->SharedPtr()); + } +} + +// This test fails +void test_fails(){ + std::stringstream ss; + { + boost::shared_ptr b(new Derived()); + Derived* raw_d1 = static_cast(b.get()); + raw_d1->m_base = 1; + raw_d1->m_derived = 2; + + // Get a raw pointer to Derived via shared_ptr + Derived* raw_d = static_cast(b.get()); + + // Verify base and derived members + BOOST_CHECK(raw_d->m_base==1); + BOOST_CHECK(raw_d->m_derived==2); + + // verify shared_from_this + boost::shared_ptr d = raw_d->SharedPtr(); + BOOST_CHECK(d == b); + // Serialize the vector + boost::archive::text_oarchive oa(ss); + oa & BOOST_SERIALIZATION_NVP(b); + } + { + // Deserialize it back into a vector of shared_ptr + ss.seekg(0); + boost::archive::text_iarchive ia(ss); + boost::shared_ptr b; + ia & BOOST_SERIALIZATION_NVP(b); + + // Get a raw pointer to Derived via shared_ptr + Derived* raw_d = static_cast(b.get()); + // Verify base and derived members + BOOST_CHECK(raw_d->m_base==1); + BOOST_CHECK(raw_d->m_derived==2); + + // verify shared_from_this + // FAIL: The following line throws bad_weak_ptr exception + boost::shared_ptr d = raw_d->SharedPtr(); + BOOST_CHECK(d == b); + } +} + +int test_main(int /*argc*/, char * /*argv */[]){ + test_fails(); + test_passes(); + return EXIT_SUCCESS; +} + +// EOF diff --git a/test/test_unique_ptr.cpp b/test/test_unique_ptr.cpp index 173d34ff..905e0b47 100644 --- a/test/test_unique_ptr.cpp +++ b/test/test_unique_ptr.cpp @@ -6,11 +6,7 @@ // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include -#include #include -#include - #include // remove, std::autoptr inteface wrong in dinkumware #include #if defined(BOOST_NO_STDC_NAMESPACE) @@ -18,9 +14,11 @@ namespace std{ using ::remove; } #endif +#ifndef BOOST_NO_CXX11_SMART_PTR +#include +#endif #include -#include #include "test_tools.hpp" @@ -55,6 +53,7 @@ void load(std::unique_ptr & spa, const char *filename) } int test_main(int /* argc */, char * /* argv */[]){ + #ifndef BOOST_NO_CXX11_SMART_PTR const char * testfile = boost::archive::tmpnam(NULL); BOOST_REQUIRE(NULL != testfile); @@ -72,5 +71,6 @@ int test_main(int /* argc */, char * /* argv */[]){ // obj of type A gets destroyed // as auto_ptr goes out of scope std::remove(testfile); + #endif // BOOST_NO_CXX11_SMART_PTR return EXIT_SUCCESS; } From ed0ba055c8bef760fdd7adcec76ecefc24ab2ecd Mon Sep 17 00:00:00 2001 From: Robert Ramey Date: Thu, 20 Feb 2014 08:33:32 -0800 Subject: [PATCH 2/5] correction for shared_ptr_helper and test_unique_ptr --- .../boost/serialization/shared_ptr_helper.hpp | 42 ++++++++--------- test/test_unique_ptr.cpp | 45 +++++++------------ 2 files changed, 39 insertions(+), 48 deletions(-) diff --git a/include/boost/serialization/shared_ptr_helper.hpp b/include/boost/serialization/shared_ptr_helper.hpp index 276c13a4..a8824365 100644 --- a/include/boost/serialization/shared_ptr_helper.hpp +++ b/include/boost/serialization/shared_ptr_helper.hpp @@ -101,6 +101,26 @@ public: const unsigned int file_version ); #endif + template + struct non_polymorphic { + static const boost::serialization::extended_type_info * + get_object_type(U & ){ + return & boost::serialization::singleton< + BOOST_DEDUCED_TYPENAME + boost::serialization::type_info_implementation< U >::type + >::get_const_instance(); + } + }; + template + struct polymorphic { + static const boost::serialization::extended_type_info * + get_object_type(U & u){ + return boost::serialization::singleton< + BOOST_DEDUCED_TYPENAME + boost::serialization::type_info_implementation< U >::type + >::get_const_instance().get_derived_extended_type_info(u); + } + }; public: template @@ -113,30 +133,12 @@ public: = & boost::serialization::type_info_implementation< T >::type ::get_const_instance(); - struct non_polymorphic { - static const boost::serialization::extended_type_info * - get_object_type(T &){ - return & boost::serialization::singleton< - BOOST_DEDUCED_TYPENAME - boost::serialization::type_info_implementation< T >::type - >::get_const_instance(); - } - }; - struct polymorphic { - static const boost::serialization::extended_type_info * - get_object_type(T & t){ - return boost::serialization::singleton< - BOOST_DEDUCED_TYPENAME - boost::serialization::type_info_implementation< T >::type - >::get_const_instance().get_derived_extended_type_info(t); - } - }; // get pointer to the most derived object's eti. This is effectively // the object type identifer typedef BOOST_DEDUCED_TYPENAME mpl::if_< is_polymorphic< T >, - polymorphic, - non_polymorphic + polymorphic, + non_polymorphic >::type type; const boost::serialization::extended_type_info * true_type diff --git a/test/test_unique_ptr.cpp b/test/test_unique_ptr.cpp index 905e0b47..955cdeaa 100644 --- a/test/test_unique_ptr.cpp +++ b/test/test_unique_ptr.cpp @@ -38,39 +38,28 @@ public: ~A(){} // default destructor }; -void save(const std::unique_ptr & spa, const char *filename) -{ - test_ostream os(filename, TEST_STREAM_FLAGS); - test_oarchive oa(os, TEST_ARCHIVE_FLAGS); - oa << BOOST_SERIALIZATION_NVP(spa); -} - -void load(std::unique_ptr & spa, const char *filename) -{ - test_istream is(filename, TEST_STREAM_FLAGS); - test_iarchive ia(is, TEST_ARCHIVE_FLAGS); - ia >> BOOST_SERIALIZATION_NVP(spa); -} - int test_main(int /* argc */, char * /* argv */[]){ #ifndef BOOST_NO_CXX11_SMART_PTR - const char * testfile = boost::archive::tmpnam(NULL); - BOOST_REQUIRE(NULL != testfile); + const char * filename = boost::archive::tmpnam(NULL); + BOOST_REQUIRE(NULL != filename); // create a new auto pointer to ta new object of type A std::unique_ptr spa(new A); - // serialize it - save(spa, testfile); - // reset the auto pointer to NULL - // thereby destroying the object of type A - // note that the reset automagically maintains the reference count - spa.reset(); - // restore state to one equivalent to the original - // creating a new type A object - load(spa, testfile); - // obj of type A gets destroyed - // as auto_ptr goes out of scope - std::remove(testfile); + { + test_ostream os(filename, TEST_STREAM_FLAGS); + test_oarchive oa(os, TEST_ARCHIVE_FLAGS); + oa << BOOST_SERIALIZATION_NVP(spa); + } + { + // reset the auto pointer to NULL + // thereby destroying the object of type A + // note that the reset automagically maintains the reference count + spa.reset(); + test_istream is(filename, TEST_STREAM_FLAGS); + test_iarchive ia(is, TEST_ARCHIVE_FLAGS); + ia >> BOOST_SERIALIZATION_NVP(spa); + std::remove(filename); + } #endif // BOOST_NO_CXX11_SMART_PTR return EXIT_SUCCESS; } From c8cb85339de19f5b6fd515959a0eec4b415dd55c Mon Sep 17 00:00:00 2001 From: Robert Ramey Date: Sat, 22 Feb 2014 11:11:29 -0800 Subject: [PATCH 3/5] corrected test in the absence of C++11 support for smart pointers --- test/test_shared_ptr.cpp | 2 ++ test/test_unique_ptr.cpp | 17 +++++++++++------ test/test_utf8_codecvt.cpp | 5 ++--- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/test/test_shared_ptr.cpp b/test/test_shared_ptr.cpp index 1aa4cb75..56b0bdf6 100644 --- a/test/test_shared_ptr.cpp +++ b/test/test_shared_ptr.cpp @@ -316,7 +316,9 @@ int test_main(int /* argc */, char * /* argv */[]) { bool result = true; result &= test(); + #ifndef BOOST_NO_CXX11_SMART_PTR result &= test(); + #endif return result ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/test/test_unique_ptr.cpp b/test/test_unique_ptr.cpp index 955cdeaa..f40b91b4 100644 --- a/test/test_unique_ptr.cpp +++ b/test/test_unique_ptr.cpp @@ -14,10 +14,6 @@ namespace std{ using ::remove; } #endif -#ifndef BOOST_NO_CXX11_SMART_PTR -#include -#endif - #include #include "test_tools.hpp" @@ -38,8 +34,10 @@ public: ~A(){} // default destructor }; +#ifndef BOOST_NO_CXX11_SMART_PTR +#include + int test_main(int /* argc */, char * /* argv */[]){ - #ifndef BOOST_NO_CXX11_SMART_PTR const char * filename = boost::archive::tmpnam(NULL); BOOST_REQUIRE(NULL != filename); @@ -60,6 +58,13 @@ int test_main(int /* argc */, char * /* argv */[]){ ia >> BOOST_SERIALIZATION_NVP(spa); std::remove(filename); } - #endif // BOOST_NO_CXX11_SMART_PTR return EXIT_SUCCESS; } + +#else + +int test_main(int /* argc */, char * /* argv */[]){ + return EXIT_SUCCESS; +} + +#endif // BOOST_NO_CXX11_SMART_PTR diff --git a/test/test_utf8_codecvt.cpp b/test/test_utf8_codecvt.cpp index e4e2558d..3d35b5e1 100644 --- a/test/test_utf8_codecvt.cpp +++ b/test/test_utf8_codecvt.cpp @@ -125,10 +125,9 @@ wchar_t test_data<4>::wchar_encoding[] = { int test_main(int /* argc */, char * /* argv */[]) { - std::locale old_loc; std::locale * utf8_locale = boost::archive::add_facet( - old_loc, + std::locale::classic(), new boost::archive::detail::utf8_codecvt_facet ); @@ -140,7 +139,7 @@ test_main(int /* argc */, char * /* argv */[]) { // Send our test UTF-8 data to file { std::ofstream ofs; - ofs.open("test.dat", std::ios::binary); + ofs.open("test.dat"); std::copy( td::utf8_encoding, #if ! defined(__BORLANDC__) From 818333c7fd61d1f25bdbb10c95b8710e699776e5 Mon Sep 17 00:00:00 2001 From: Robert Ramey Date: Sun, 23 Feb 2014 11:21:13 -0800 Subject: [PATCH 4/5] added #if def to skip std::shared_ptr test when compiler doesn't support C++11 --- test/test_shared_ptr_multi_base.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/test_shared_ptr_multi_base.cpp b/test/test_shared_ptr_multi_base.cpp index f392a5dd..6a35f2c1 100644 --- a/test/test_shared_ptr_multi_base.cpp +++ b/test/test_shared_ptr_multi_base.cpp @@ -144,12 +144,14 @@ void load2( template boost::shared_ptr dynamic_pointer_cast(boost::shared_ptr & u){ return boost::dynamic_pointer_cast(u); -}; +} +#ifndef BOOST_NO_CXX11_SMART_PTR template std::shared_ptr dynamic_pointer_cast(std::shared_ptr & u){ return std::dynamic_pointer_cast(u); -}; +} +#endif // Serialization sequence // First, shared_ptr @@ -285,6 +287,8 @@ int test_main(int /* argc */, char * /* argv */[]) { bool result = true; result &= test(); + #ifndef BOOST_NO_CXX11_SMART_PTR result &= test(); + #endif return result ? EXIT_SUCCESS : EXIT_FAILURE; } \ No newline at end of file From a9a4f6da0b5ee7ca38381076efe29a3f47be4519 Mon Sep 17 00:00:00 2001 From: Robert Ramey Date: Fri, 28 Feb 2014 10:50:19 -0800 Subject: [PATCH 5/5] fixed interface to dynamic_cast tweaked archives to use/restore original local rather than the global "classic" one --- .../boost/archive/impl/xml_wiarchive_impl.ipp | 2 +- .../boost/archive/impl/xml_woarchive_impl.ipp | 2 +- test/test_shared_ptr_multi_base.cpp | 28 +++++++++++-------- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/include/boost/archive/impl/xml_wiarchive_impl.ipp b/include/boost/archive/impl/xml_wiarchive_impl.ipp index b2c7cced..9cff24b3 100644 --- a/include/boost/archive/impl/xml_wiarchive_impl.ipp +++ b/include/boost/archive/impl/xml_wiarchive_impl.ipp @@ -174,7 +174,7 @@ xml_wiarchive_impl::xml_wiarchive_impl( if(0 == (flags & no_codecvt)){ archive_locale.reset( add_facet( - std::locale::classic(), + is_.getloc(), new boost::archive::detail::utf8_codecvt_facet ) ); diff --git a/include/boost/archive/impl/xml_woarchive_impl.ipp b/include/boost/archive/impl/xml_woarchive_impl.ipp index ff97daa5..221ac6be 100644 --- a/include/boost/archive/impl/xml_woarchive_impl.ipp +++ b/include/boost/archive/impl/xml_woarchive_impl.ipp @@ -155,7 +155,7 @@ xml_woarchive_impl::xml_woarchive_impl( #else pfacet = new boost::archive::detail::utf8_codecvt_facet; #endif - archive_locale.reset(add_facet(std::locale::classic(), pfacet)); + archive_locale.reset(add_facet(os_.getloc(), pfacet)); os.imbue(* archive_locale); } if(0 == (flags & no_header)) diff --git a/test/test_shared_ptr_multi_base.cpp b/test/test_shared_ptr_multi_base.cpp index 6a35f2c1..245ea510 100644 --- a/test/test_shared_ptr_multi_base.cpp +++ b/test/test_shared_ptr_multi_base.cpp @@ -142,13 +142,17 @@ void load2( // objects back from an archive. template -boost::shared_ptr dynamic_pointer_cast(boost::shared_ptr & u){ +boost::shared_ptr dynamic_pointer_cast(boost::shared_ptr const & u) +BOOST_NOEXCEPT +{ return boost::dynamic_pointer_cast(u); } #ifndef BOOST_NO_CXX11_SMART_PTR template -std::shared_ptr dynamic_pointer_cast(std::shared_ptr & u){ +std::shared_ptr dynamic_pointer_cast(std::shared_ptr const & u) +BOOST_NOEXCEPT +{ return std::dynamic_pointer_cast(u); } #endif @@ -156,10 +160,10 @@ std::shared_ptr dynamic_pointer_cast(std::shared_ptr & u){ // Serialization sequence // First, shared_ptr // Second, weak_ptr -template +template void shared_weak( - FIRST & first, - SECOND & second + SP & first, + WP & second ){ const char * testfile = boost::archive::tmpnam(NULL); BOOST_REQUIRE(NULL != testfile); @@ -178,8 +182,8 @@ void shared_weak( BOOST_CHECK(firstm == first->m_x); BOOST_CHECK(secondm == second.lock()->m_x); // Check pointer to vtable - BOOST_CHECK(dynamic_pointer_cast(first)); - BOOST_CHECK(dynamic_pointer_cast(second.lock())); + BOOST_CHECK(::dynamic_pointer_cast(first)); + BOOST_CHECK(::dynamic_pointer_cast(second.lock())); std::remove(testfile); } @@ -187,10 +191,10 @@ void shared_weak( // Serialization sequence // First, weak_ptr // Second, shared_ptr -template +template void weak_shared( - FIRST & first, - SECOND & second + WP & first, + SP & second ){ const char * testfile = boost::archive::tmpnam(NULL); BOOST_REQUIRE(NULL != testfile); @@ -208,8 +212,8 @@ void weak_shared( BOOST_CHECK(firstm == first.lock()->m_x); BOOST_CHECK(secondm == second->m_x); // Check pointer to vtable - BOOST_CHECK(dynamic_pointer_cast(first.lock())); - BOOST_CHECK(dynamic_pointer_cast(second)); + BOOST_CHECK(::dynamic_pointer_cast(first.lock())); + BOOST_CHECK(::dynamic_pointer_cast(second)); std::remove(testfile); }