Boost logo

Boost :

Subject: [boost] [serialization] [1.41] serialization of shared_ptr<> fails to compile
From: Marco Jez (marco.jez_at_[hidden])
Date: 2009-11-23 09:29:42


Hello, I'm still having troubles with Boost.Serialization in Boost 1.41.
The following example code fails to compile with latest Boost release, while
it works with 1.39:

#include <boost/archive/binary_iarchive.hpp>
#include <boost/serialization/shared_ptr.hpp>
#include <boost/shared_ptr.hpp>
#include <iostream>

// dummy struct with no actual serialization code
struct Test { template<typename A> void serialize(A &, unsigned) {} };

int main()
{
        boost::archive::binary_iarchive ia(std::cin);

        boost::shared_ptr<Test> x;
        ia & x;

        return 0;
}

The compiler (MSVC 9) gives me this error:
error C2440: 'return' : cannot convert from 'const
boost::serialization::extended_type_info_typeid<T>' to 'const
boost::serialization::extended_type_info *'c:\boost\include\boost-1_41\boost\archive\shared_ptr_helper.hppIt seems that an address-of (&) operator is required in
shared_ptr_helper.hpp at line 111, that is:

...
            return boost::serialization::singleton<
...

should read:

...
            return &boost::serialization::singleton<
...

This change makes my code compile, but I'm not sure whether it's an
appropriate fix or not, as I don't know Serialization's internals.

Cheers,
Marco
 


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk