Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-09-11 11:33:00

From: "Vladimir Prus"

> Peter Dimov wrote:
> >
> > If you are willing to confine yourself to a given
> > 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.

Well, yes, for some suitable definition of "demangler". :-)

> >>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.
> > haven't been able to avoid it.
> Why can't polymorphic classes be registered globally?

I misread your statement above; my code currently requires that you register
the (reader/writer, class) type pair. Registration is global.

On the other hand, I don't handle pointers well, if at all, so I can't
really say whether Robert Ramey's approach is needlessly restrictive.

> > 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
> > 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'?

Here is what I do currently:

struct X
    explicit X(int i = 0): i(i)

    virtual ~X()

    int i;

template<class R> void read(R & r, X & x)
    read(r, x.i);

template<class W> void write(W & w, X const & x)
    write(w, x.i);

template<class W, class A> void write(W & w, X const & x, A const & a)
    begin_struct(w, a);
    write(w, x.i, "i");
    end_struct(w, a);

This is quite repetitive and error-prone, but without reflection/metadata...

Boost list run by bdawes at, gregod at, cpdaniel at, john at