mirror of
https://github.com/USCiLab/cereal.git
synced 2025-09-22 21:09:33 +02:00
Considering #44 fixed
Need to do a once over on documentation to finish up, see issue #22
This commit is contained in:
parent
6f7ca3ea99
commit
2b25a7b3d6
@ -149,13 +149,13 @@ namespace cereal
|
||||
// Member load_and_allocate
|
||||
template<typename T, typename A>
|
||||
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
|
||||
template<typename T, typename A>
|
||||
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
|
||||
|
@ -1022,11 +1022,11 @@ struct MemoryCycle
|
||||
{ }
|
||||
|
||||
int value;
|
||||
std::shared_ptr<MemoryCycle> ptr;
|
||||
std::weak_ptr<MemoryCycle> ptr;
|
||||
|
||||
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>
|
||||
@ -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<MemoryCycleLoadAndAllocate> p ) :
|
||||
std::weak_ptr<MemoryCycleLoadAndAllocate> 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 <class Archive>
|
||||
@ -1070,19 +1070,19 @@ class MemoryCycleLoadAndAllocate
|
||||
static void load_and_allocate( Archive & ar, cereal::allocate<MemoryCycleLoadAndAllocate> & allocate )
|
||||
{
|
||||
int value;
|
||||
std::shared_ptr<MemoryCycleLoadAndAllocate> ptr;
|
||||
std::weak_ptr<MemoryCycleLoadAndAllocate> ptr;
|
||||
|
||||
ar( value, ptr );
|
||||
allocate( value, ptr );
|
||||
}
|
||||
|
||||
int value;
|
||||
std::shared_ptr<MemoryCycleLoadAndAllocate> ptr;
|
||||
std::weak_ptr<MemoryCycleLoadAndAllocate> 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() );
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user