Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2005-01-15 12:11:11


Larry Evans wrote:
> The code in:
>
> http://boost-sandbox.sourceforge.net/vault/inherit_linearly_test.cpp
>
> provides easy access to the elements of inherit_linearly

?? inherit_linearly is a metafunction. It doesn't have elements. Maybe
you mean the result of invoking it?

> with:
>
> get_tail<inherit_linearly<...>, i>::head_type
>
> which returns the i-th element in the inheritance heirarchy. Couldn't
> this be used to generate member names using templates?

No, as the book says, there really is no way to generate member names
using templates.

> For example,
> the "name" of the i-th value on p. 191 of the
>
> _C++ Template Metaprogramming_
>
> book would be:
>
> r.get_tail<inherit_linearly<...>, i>::head_type::value

That's not a name; it's an expression.
Also, your sample code has no get_tail member template, so I don't see
how that could compile...

> where r is an instance of:
>
> inherit_linearly<types, inherit_head_tail<wrap<_2>,_1> >::type

...that said, this doesn't seem like a particularly original idea. It
seems like a complicated way of expressing what boost::tuples::get
already provides. Am I missing something?

-- 
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com

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