Boost logo

Boost Users :

Subject: Re: [Boost-users] [Boost.Serialization] Serializing "abstract"classes
From: Júlio Hoffimann (julio.hoffimann_at_[hidden])
Date: 2011-08-06 15:38:51


I think this is one of the tricky things that turns C++ a complex
language! The *this object is in fact of type B, even inside a virtual
function because the B& operator*(B*) is called. I was using
typeid(*this).name() to debug, without knowing it's virtual behavior.

The solution is simple to remove the "*" from "*this", serialization is fine
through the pointers! About the warning, it has no relation with this
problem, occurs because i'm using an old version of Boost.

Thank you Robert for your attention, don't need to waste time thinking on
this. :-)

Living and learning C++,
Júlio.

2011/8/5 Júlio Hoffimann <julio.hoffimann_at_[hidden]>

> Yes, but why?
>
> ../libs/boost/include/boost/serialization/export.hpp:134:40: warning: type
> qualifiers ignored on function return type
> main.cpp:83:5: warning: unused parameter ‘argc’
> main.cpp:83:5: warning: unused parameter ‘argv’
>
> Can you reproduce the error in your Boost version?
>
> 2011/8/5 Robert Ramey <ramey_at_[hidden]>
>
>> Júlio Hoffimann wrote:
>> > Just correcting another mistake mine, the warning is not on line 40
>> > as i said. It's in export.hpp 134:40.
>> >
>>
>> That's where it's detected. It's caused somehere else - see below.
>>
>> >
>> > Do you have any hint Robert? What could i do to fix this? I heard
>> > Boost.Serialization changed dramatically from 1.45 to actual
>> > versions. I just don't want to upgrade right now because i'm the
>> > middle of another job.
>> >
>>
>> One obvious problem is that the base class is not abstract. To be
>> abstract,
>> a base class must have atleast one virtual function in the form
>>
>> virtual my_function() = 0;
>>
>> The ASSUME_ABSTRACT macro doesn't mark it abstract to the
>> compiler - it marks it abstract to the boost type-traites system.
>> I know it's quirky and unclear - but I see no way to make it bullet proof.
>>
>> I'm sort of surprised/disappointed that this doesn't give a compile time
>> warning. What compiler do you use?
>>
>> Robert Ramey
>>
>>
>>
>>
>> _______________________________________________
>> Boost-users mailing list
>> Boost-users_at_[hidden]
>> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>>
>
>



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