Boost logo

Boost :

From: Douglas Gregor (gregod_at_[hidden])
Date: 2001-06-20 09:57:49


On Wednesday 20 June 2001 10:21, you wrote:
> I skimmed them (admittedly), but still don't know what "tagging hierarchy
> versions" means.
> -Dave

There's an extra template parameter (a 'tag') that is required to delay
instantiation of template classes. The tag also can be used to specify
extensions. From that example in the paper, we have a Widget hierarchy and
two disjoint extensions: an Audible interface and a Handheld interface. We
can use:

Widget<Audible>

to get the audible interface, or

Widget<Handheld>

to get the handheld interface.

Composing interfaces turns out to be easy. You just create a new tag
representing the union of the 'audible' and 'handheld' interfaces, then use
two injections: the first injects all bases introduced by Audible and the
second injects all bases introduced by Handheld.

struct AudibleAndHandheld {};

template<>
struct base_class<Widget<AudibleAndHandheld>, 0> {
  typedef bases< Widget<Audible> > base;
};

template<>
struct base_class<Widget<AudibleAndHandheld>, 1> {
  typedef bases< Widget<Handheld> > base;
};

Tags allow multiple versions of the same hierarchy to coexist in a
translation unit, essentially, and composition of tags allows multiple
interfaces to be wrapped into a hierarchy (but all interfaces remain
distinct).

        Doug

> ----- Original Message -----
> From: "Douglas Gregor" <gregod_at_[hidden]>
> To: <boost_at_[hidden]>
> Sent: Wednesday, June 20, 2001 10:02 AM
> Subject: Re: [boost] Re: Base Class Injection
>
> > The PDF docs will shed much more light. It should answer all of your
> > questions below.
> >
> > On Wednesday 20 June 2001 09:23, you wrote:
> > > I just took a look at the HTML documentation. I found it left me with
>
> many
>
> > > questions. For example, how is the "base class counter" used? If I am
> > > supposed to increment it to inject multiple bases, how does that jibe
>
> with
>
> > > the example at the bottom of the page? What does "tagging hierarchy
> > > versions" mean? This section is completely lost on me. Also, the docs
>
> need
>
> > > some motivating explanation. Why would I want to do this? It seems
> > > preferable to me, as long as I am going to end up with a class template
> > > anyway, to make it adaptable so I can make any number of different
> > > variations (c.f. iterator_adaptor) rather than just changing the bases
>
> of
>
> > > what is essentially a single entity.
> > >
> > > -Dave
> > >
> > > Maybe the PDF docs will shed more light...
> >
> > Doug
> >
> > Info: http://www.boost.org Unsubscribe:
>
> <mailto:boost-unsubscribe_at_[hidden]>
>
> > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
> Info: http://www.boost.org Unsubscribe:
> <mailto:boost-unsubscribe_at_[hidden]>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/


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