Considering #44 fixed

Need to do a once over on documentation to finish up, see issue #22
This commit is contained in:
Shane Grant
2014-01-22 16:57:07 -08:00
parent 6f7ca3ea99
commit 2b25a7b3d6
2 changed files with 12 additions and 12 deletions

View File

@@ -149,13 +149,13 @@ namespace cereal
// Member load_and_allocate // Member load_and_allocate
template<typename T, typename A> template<typename T, typename A>
struct has_member_load_and_allocate : struct has_member_load_and_allocate :
std::integral_constant<bool, std::is_same<decltype( access::load_and_allocate<T>( std::declval<A&>(), std::declval<::cereal::allocate<T>&>() ) ), void>::value> {}; std::integral_constant<bool, std::is_same<decltype( access::load_and_allocate<T>( std::declval<A&>(), std::declval< ::cereal::allocate<T>&>() ) ), void>::value> {};
// ###################################################################### // ######################################################################
// Non Member load_and_allocate // Non Member load_and_allocate
template<typename T, typename A> template<typename T, typename A>
struct has_non_member_load_and_allocate : std::integral_constant<bool, struct has_non_member_load_and_allocate : std::integral_constant<bool,
std::is_same<decltype( LoadAndAllocate<T>::load_and_allocate( std::declval<A&>(), std::declval<::cereal::allocate<T>&>() ) ), void>::value> {}; std::is_same<decltype( LoadAndAllocate<T>::load_and_allocate( std::declval<A&>(), std::declval< ::cereal::allocate<T>&>() ) ), void>::value> {};
// ###################################################################### // ######################################################################
// Has either a member or non member allocate // Has either a member or non member allocate

View File

@@ -1022,11 +1022,11 @@ struct MemoryCycle
{ } { }
int value; int value;
std::shared_ptr<MemoryCycle> ptr; std::weak_ptr<MemoryCycle> ptr;
bool operator==( MemoryCycle const & other ) const bool operator==( MemoryCycle const & other ) const
{ {
return value == other.value && ptr == other.ptr; return value == other.value && ptr.lock() == other.ptr.lock();
} }
template <class Archive> template <class Archive>
@@ -1038,7 +1038,7 @@ struct MemoryCycle
std::ostream& operator<<(std::ostream& os, MemoryCycle const & s) 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; return os;
} }
@@ -1050,14 +1050,14 @@ class MemoryCycleLoadAndAllocate
{ } { }
MemoryCycleLoadAndAllocate( int v, MemoryCycleLoadAndAllocate( int v,
std::shared_ptr<MemoryCycleLoadAndAllocate> p ) : std::weak_ptr<MemoryCycleLoadAndAllocate> p ) :
value( v ), value( v ),
ptr( p ) ptr( p )
{ } { }
bool operator==( MemoryCycleLoadAndAllocate const & other ) const bool operator==( MemoryCycleLoadAndAllocate const & other ) const
{ {
return value == other.value && ptr == other.ptr; return value == other.value && ptr.lock() == other.ptr.lock();
} }
template <class Archive> template <class Archive>
@@ -1070,19 +1070,19 @@ class MemoryCycleLoadAndAllocate
static void load_and_allocate( Archive & ar, cereal::allocate<MemoryCycleLoadAndAllocate> & allocate ) static void load_and_allocate( Archive & ar, cereal::allocate<MemoryCycleLoadAndAllocate> & allocate )
{ {
int value; int value;
std::shared_ptr<MemoryCycleLoadAndAllocate> ptr; std::weak_ptr<MemoryCycleLoadAndAllocate> ptr;
ar( value, ptr ); ar( value, ptr );
allocate( value, ptr ); allocate( value, ptr );
} }
int value; int value;
std::shared_ptr<MemoryCycleLoadAndAllocate> ptr; std::weak_ptr<MemoryCycleLoadAndAllocate> ptr;
}; };
std::ostream& operator<<(std::ostream& os, MemoryCycleLoadAndAllocate const & s) 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; return os;
} }
@@ -1119,9 +1119,9 @@ void test_memory_cycles()
} }
BOOST_CHECK_EQUAL( o_ptr1->value, i_ptr1->value ); 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( 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() );
} }
} }