Boost logo

Boost :

From: Loïc Joly (loic.actarus.joly_at_[hidden])
Date: 2005-09-09 03:24:54


Hello everybody,

There a still many stuff I do not understand how to do with
boost::serialization. One of them is the following :

Let's say I have the following classes :

struct B
{
    int i;
    template<class Archive> void serialize(Archive & ar, const unsigned
int version) { ar & i;}
};

struct A
{
    B const *pc;
    template<class Archive> void serialize(Archive & ar, const unsigned
int version)
    {
        ar & pc;
    }
};

When I try to serialize a A, I get the following error (MSVC8 beta 2):
c:\boost\include\boost-1_33\boost\archive\detail\iserializer.hpp(474) :
error C2440: 'reinterpret_cast' : cannot convert from 'const B **__w64 '
to 'void **'
        Conversion loses qualifiers
        
c:\boost\include\boost-1_33\boost\archive\detail\iserializer.hpp(471) :
while compiling class template member function 'void
boost::archive::detail::load_pointer_type<Archive,Tptr>::invoke(Archive
&,Tptr &)'
        with
        [
            Archive=boost::archive::text_iarchive,
            Tptr=const B *
        ]

Of course, if I replace B const *pc by B *pc, then the code works
correctly.What can I do to serialize pointers to const data ?

Regards,

-- 
Loïc

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