Boost logo

Boost :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2002-09-11 11:05:35


Peter Dimov wrote:
> From: "Vladimir Prus" <ghost_at_[hidden]>
>
>>Peter Dimov wrote:
>>
>>>From: "Vladimir Prus" <ghost_at_[hidden]>
>>>
>>>>I have tried hard to explain that while typeid would make archives
>>>>unportable between different machines (not really an issue if there's
>>>>denamgler for type_info::name() and I think work is underway on it),
>>>
>>>
>>>An issue. You never know whether, or how, type_info::name() is mangled,
>>
> or
>
>>>whether there is type_info::name() at all (speaking of portable code.)
>>
>>You still know that for any given platform.
>
>
> If you are willing to confine yourself to a given platform/compiler/version,
> which I am not, you don't need to demangle type_info::name.

Why confine yourself to a single platform. If you have
platform-dependent demanglers for type_info::name(), then everything
else should be portable.

>>>The only portable C++-only solution (AFAIK) is to require registration
>>
> of
>
>>>all polymorphic types, including an identifier that uniquely describes
>>
> the
>
>>>type.
>>
>>You see, proposed serialization library requires much more than that. It
>>requires the you
>>1. Register all polymorphic classes with any instance of
>>basic_{i,o}archive that you create
>
>
> My own serialization framework has the same requirement, unfortunately. I
> haven't been able to avoid it.

Why can't polymorphic classes be registered globally?

>>>Not only that, but you also need to register derived to base
>>
> conversions,
>
>>>too, as I recently realized, since Derived * -> void * -> Base * is not
>>>required to work.
>>
>>Why do you need such a conversion?
>
>
> Because when you are reading a polymorphic object via a pointer to Base, you
> don't have Derived available at compile time; you only have a string that
> identifies that Derived. You can dispatch on that string and get back a
> void* to the object; now you must convert that void* to a Base*.
>
>
>>>>Except
>>>>1. It's much more terse
>>>
>>>
>>>And much less const-correct.
>>
>>You mean that if 'describe' is not declared const, you can't serialize
>>const object without const_cast somewhere? Seems so. Did you say this
>>before?
>
>
> Yes, I did. :-)
>
> Having to write essentially the same code twice seems inconvenient, but I am
> willing to pay the price. In fact currently I'm writing the same code three
> times (the third variation includes variable names).

Oh... I thought about variable names too! Did I understood correctly
that you use scheme with const and non-const 'describe'?

- Volodya

>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost


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