Boost logo

Boost Users :

From: Sascha Friedmann (sascha.friedmann_at_[hidden])
Date: 2006-08-08 08:35:26


Hello,
I have a problem with serializing smart_ptrs. I have tried both the
boost::scoped_ptr and the boost::shared_ptr but I get always the same error:

Boost1-33\include\boost-1_33\boost\archive\detail\oserializer.hpp(566):
error C2027: Use of undefined type "boost::STATIC_ASSERTION_FAILURE<x>"
         with
         [
             x=false
         ]

My example program:
#include <boost/archive/tmpdir.hpp>

#include <boost/archive/text_oarchive.hpp>

#include <boost/archive/text_iarchive.hpp>

#include <boost/serialization/shared_ptr.hpp>

struct Foo

{

int i;

Foo( int j )

: i( j )

{

}

template< class T >

void serialize( T& ar, const unsigned int ver )

{

ar & i;

}

};

struct Test

{

boost::shared_ptr< Foo > t1;

boost::shared_ptr< Foo > t2;

Test()

: t1( new Foo( 3 ) ), t2( t1 )

{

}

template< class Ar >

void save( Ar& ar, const unsigned int ver )

{

ar << t1;

ar << t2;

}

template< class Ar >

void load( Ar& ar, const unsigned int ver )

{

ar >> t1;

ar >> t2;

}

BOOST_SERIALIZATION_SPLIT_MEMBER();

};

int main( int argc, char* argv[] )

{

Test t;

std::ofstream ofs( "test.txt" );

boost::archive::text_oarchive out( ofs );

out << t;

}

I hope someone can help me (google and the documentation couldn't :()

Sascha Friedmann


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net