|
Boost : |
From: David Abrahams (dave_at_[hidden])
Date: 2002-11-21 10:28:24
I'd like to start a dialogue about how to bridge compile-time and
runtime metaprogramming. To start with, I have some simple problems to
solve:
1. I have an MPL type sequence S and a metafunction (class) F. I want
to build a tuple type where the type of each tuple element is given
by F(e) for each e in S.
I think this is as simple as defining push_front<> for tuple cons
elements and using fold_backward<> to build the tuple.
2. I have a runtime iterator range over some values of a uniform type
X, and a type sequence which describes conversion functors from
X->T1, X->T2,... X->TN. I also have a tuple type with element types
T1', T2',... TN'. Now I want to construct the tuple with the
results of calling these functors on the corresponding elements of
the type sequence. Note that Ti might be a reference type, so
two-phase construction isn't an option.
3. Well, I have already solved this problem (see
boost/python/detail/def_helper.hpp), but I'd like to ask once again
for consideration of an inherits-from-tail tuple implementation in
the context of metaprogramming with tuples. The aforementioned file
demonstrates why I think it would be useful. It is extracting from
a tuple the value of the first type which fulfills some
compile-time predicate. I believe that's a very common pattern. On
the other hand, I do see some downsides to using a
public-inheritance-from-tail implementation, so maybe we should
just package the tuple_extract algorithm as a separate library and
be done with it ;-)
-- David Abrahams dave_at_[hidden] * http://www.boost-consulting.com Boost support, enhancements, training, and commercial distribution
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk