Boost logo

Boost :

Subject: [boost] [serialization] Technique used for registration of derived through base ( Abrahams wizardy )
From: Sebastian Karlsson (sairony_at_[hidden])
Date: 2011-10-11 10:08:07


A good while ago I got interested in how the registration process
works in boost::serialization, I was never able to understand how the
technique works, even if the gist of it is contained in 2 fairly small
headers ( boost/serialization/export.hpp &
boost/archive/detail/register_archive.hpp ). It would seem the creator
of the technique is David Abrahams, so I'm hoping he or anyone else
which understands how the registration process works could explain the
technique used.

>From my understanding it solves the problem of having 2 different
sequences of types, and then being able to operate on all the
combinations. All the techniques I've seen used previously for this
requires the maintenance of some sort of compile time vector of one of
the sequences. This is very cumbersome, not only does it needs to
manually managed, but the file that defines the vector turns into a
large dependency bottleneck. From my understanding the technique used
in boost::serialization currently one sequence simply adds an overload
to a free function, then at the registration point of the other
sequence just having the overloads considered at compile time causes
the magic to happen when the return type needs to instantiated. Unless
I'm missing something obvious I think it would make for a very
interesting subject of an article or discussion on the mailing list.

Kind regards,
Sebastian Karlsson


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