Boost logo

Boost :

From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2007-01-07 16:16:55

> Is there something wrong with defining your classes in foo.hpp and
> exporting them in a foo_serialization.hpp that isn't included by
> foo.hpp?

Nothing wrong with that.

The question is where is foo_serialization.hpp #included? I am guessing that
what you have in mind is that it would be included by all compilation units
that serialize foo objects. Strictly speaking, you don't need the class
registration in those units.

It could be argued that something that serializes foo objects is physically
coupled with the serialization library anyway, so the additional coupling
with the class registration is not that big of a deal. The point I am making
is that even code that serializes foo objects doesn't have to be physically
coupled with the serialization library; all it needs is a function template
overload for serializing foo objects, which -- as I illustrated -- doesn't
have to be physically coupled with any serialization library.

Going back to your suggestion to use foo_serialization.hpp: if we assume
that all it does is register class foo (but doesn't serialize foo objects),
I don't see why it's a separate header. I'd rather have a single compilation
unit in my program which registers all archives I'm using, all necessary
upcasts and classes that need to be serialized dynamically (in that

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