Boost logo

Boost Users :

From: Sascha Friedmann (sascha.friedmann_at_[hidden])
Date: 2006-08-09 11:10:37


Robert Ramey wrote:
> Sascha Friedmann wrote:
>> 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
>> ]
>>
>
>> int main( int argc, char* argv[] )
>>
>> {
>>
>
> ****
> replace the following
>> Test t;
>
> with
>
> const 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 :()
>
> This is explained in couple of places:
>
> a) The code comment at the point where the compile time error occurs gives
> and explanation and points to more information.
> b) The Rationale section of the documentation explains this in detail
> and why this is trapped.
>>
>>
>> Sascha Friedmann
I understand now the problem, but in my real project I ran again into
this trap. After rereading the article in the rationale I understand
fully why it is trapping, but I don't want to set my class to
track_never because I can't guarantee that it is what I want. And
const_cast is no solution, too.
So the thing that is left is this construct_from class-wrapper.
But it seems it is only an example an not a part of the
boost::serialization library.
How do I write my own construct_from wrapper, that can wrap all my
objects, so that I can still create them non-const on the stack and use
them and for serializing I'm just creating such a construct_from wrapper
for an object?
While writing I'm wondering now if I'm not bypassing the system with this..

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