#ifndef BOOST_SERIALIZATION_TEST_D_HPP
#define BOOST_SERIALIZATION_TEST_D_HPP
#if defined(_MSC_VER)
# pragma once
#endif
#include <cstddef>
#include "test_tools.hpp"
#include <boost/core/no_exceptions_support.hpp>
#include <boost/serialization/throw_exception.hpp>
#include <boost/serialization/split_member.hpp>
#include "B.hpp"
class D
{
private:
friend class boost::serialization::access;
B *b1;
B *b2;
template<class Archive>
void save(Archive &ar, const unsigned int file_version) const{
ar << BOOST_SERIALIZATION_NVP(b1);
ar << BOOST_SERIALIZATION_NVP(b2);
}
template<class Archive>
void load(Archive & ar, const unsigned int file_version){
BOOST_TRY {
ar >> boost::serialization::make_nvp("b", b1);
ar >> boost::serialization::make_nvp("b", b2);
}
BOOST_CATCH (...){
b1 = NULL;
b2 = NULL;
BOOST_FAIL( "multiple identical pointers failed to load" );
}
BOOST_CATCH_END
BOOST_CHECK(b1 == b2);
}
BOOST_SERIALIZATION_SPLIT_MEMBER()
public:
D();
~D();
bool operator==(const D &rhs) const;
};
BOOST_CLASS_VERSION(D, 3)
D::D()
{
b1 = new B();
b2 = b1;
}
D::~D()
{
delete b1;
}
bool D::operator==(const D &rhs) const
{
if(! (*b1 == *(rhs.b1)) )
return false;
if(! (*b2 == *(rhs.b2)) )
return false;
return true;
}
#endif