Skip to content

Commit

Permalink
Considering #44 fixed
Browse files Browse the repository at this point in the history
Need to do a once over on documentation to finish up, see issue #22
  • Loading branch information
AzothAmmo committed Jan 23, 2014
1 parent 6f7ca3e commit 2b25a7b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions include/cereal/details/traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 10 additions & 10 deletions unittests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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;
}

Expand All @@ -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>
Expand All @@ -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;
}

Expand Down Expand Up @@ -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() );
}
}

Expand Down

0 comments on commit 2b25a7b

Please sign in to comment.