From 2b25a7b3d61966e43aa39b9cf4023cf29076d581 Mon Sep 17 00:00:00 2001 From: Shane Grant Date: Wed, 22 Jan 2014 16:57:07 -0800 Subject: [PATCH] Considering #44 fixed Need to do a once over on documentation to finish up, see issue #22 --- include/cereal/details/traits.hpp | 4 ++-- unittests.cpp | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/cereal/details/traits.hpp b/include/cereal/details/traits.hpp index ba39338fd..1e90f8a4d 100644 --- a/include/cereal/details/traits.hpp +++ b/include/cereal/details/traits.hpp @@ -149,13 +149,13 @@ namespace cereal // Member load_and_allocate template struct has_member_load_and_allocate : - std::integral_constant( std::declval(), std::declval<::cereal::allocate&>() ) ), void>::value> {}; + std::integral_constant( std::declval(), std::declval< ::cereal::allocate&>() ) ), void>::value> {}; // ###################################################################### // Non Member load_and_allocate template struct has_non_member_load_and_allocate : std::integral_constant::load_and_allocate( std::declval(), std::declval<::cereal::allocate&>() ) ), void>::value> {}; + std::is_same::load_and_allocate( std::declval(), std::declval< ::cereal::allocate&>() ) ), void>::value> {}; // ###################################################################### // Has either a member or non member allocate diff --git a/unittests.cpp b/unittests.cpp index d5e2f1746..1eb20fbd3 100644 --- a/unittests.cpp +++ b/unittests.cpp @@ -1022,11 +1022,11 @@ struct MemoryCycle { } int value; - std::shared_ptr ptr; + std::weak_ptr ptr; bool operator==( MemoryCycle const & other ) const { - return value == other.value && ptr == other.ptr; + return value == other.value && ptr.lock() == other.ptr.lock(); } template @@ -1038,7 +1038,7 @@ struct MemoryCycle std::ostream& operator<<(std::ostream& os, MemoryCycle const & s) { - os << "[value: " << s.value << " ptr: " << s.ptr << "]"; + os << "[value: " << s.value << " ptr: " << s.ptr.lock() << "]"; return os; } @@ -1050,14 +1050,14 @@ class MemoryCycleLoadAndAllocate { } MemoryCycleLoadAndAllocate( int v, - std::shared_ptr p ) : + std::weak_ptr p ) : value( v ), ptr( p ) { } bool operator==( MemoryCycleLoadAndAllocate const & other ) const { - return value == other.value && ptr == other.ptr; + return value == other.value && ptr.lock() == other.ptr.lock(); } template @@ -1070,19 +1070,19 @@ class MemoryCycleLoadAndAllocate static void load_and_allocate( Archive & ar, cereal::allocate & allocate ) { int value; - std::shared_ptr ptr; + std::weak_ptr ptr; ar( value, ptr ); allocate( value, ptr ); } int value; - std::shared_ptr ptr; + std::weak_ptr ptr; }; std::ostream& operator<<(std::ostream& os, MemoryCycleLoadAndAllocate const & s) { - os << "[value: " << s.value << " ptr: " << s.ptr << "]"; + os << "[value: " << s.value << " ptr: " << s.ptr.lock() << "]"; return os; } @@ -1119,9 +1119,9 @@ void test_memory_cycles() } BOOST_CHECK_EQUAL( o_ptr1->value, i_ptr1->value ); - BOOST_CHECK_EQUAL( i_ptr1.get(), i_ptr1->ptr.get() ); + BOOST_CHECK_EQUAL( i_ptr1.get(), i_ptr1->ptr.lock().get() ); BOOST_CHECK_EQUAL( o_ptr2->value, i_ptr2->value ); - BOOST_CHECK_EQUAL( i_ptr2.get(), i_ptr2->ptr.get() ); + BOOST_CHECK_EQUAL( i_ptr2.get(), i_ptr2->ptr.lock().get() ); } }