Boost logo

Boost :

From: JOAQUIN LOPEZ MU?Z (joaquin_at_[hidden])
Date: 2004-04-25 17:12:16


----- Mensaje original -----
De: Jeff Garland <jeff_at_[hidden]>
Fecha: Domingo, Abril 25, 2004 11:19 pm
Asunto: Re: [boost] [serialization+date_time] Serialization Review: serialization of dates
[...]
> > #include "boost/archive/basic_archive.hpp"
> > #include "boost/serialization/split_free.hpp"
> > #include "boost/serialization/string.hpp"
> >
> > I think the two first are unnecessary (could you
> > try this out? thx)
>
> Actually none of them are necessary. Ah the wonder of templates :-)
>

Wonderful they are, you're right :) So, I guess this is
as good as it can get.

Slightly OT: this issue of POI could be taken a little
further to allow interoperability between (not necessarily
template-based) libraries without the headache of having
to include portions of them. This is what I have in mind:
suppose a header-based library A provides support for or
somehow uses a non-header (i.e. requires linking) library B,
like this:

// lib A
#include <b.hpp>

inline foo(){...} // does not depend on B
inline bar(){...} // does not depend on B

inline mess_with_B(){...}

Now, if B is not linked in the project mess_with_B won't
compile, so one has to move this function to a separate
header that the user will/won't include depending of
whether she wishes that functionality. Instead, one can
do the following:

// lib A
#include <b.hpp>

inline foo(){...}
inline bar(){...}

template<typename dummy>
inline mess_with_B(dummy* =0){...}

Voila, A works even if B is not linked in. If the user
has linked B and wants to use mess_with_B, then she
just has to call mess_with_B() as usual, template
instantiation model will do the rest. Maybe I'm missing
something, but I think this approach could be
investigated a little further. One good example of
use is for interoperability with Boost.Threads, for
instance.

Totally OT: I've posted a question regarding multi_index
and composite keys a few posts ago. You being one of the
reviewers, your opinion on that is greatly appreciated :)

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo


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