On 10/6/05, David Abrahams wrote:
Geoffrey Romer writes:
On 10/6/05, David Abrahams wrote:
Oh. Maybe mapping into the runtime world will help. If you think of
metafunc as a regular function, then "metafunc::type" is
equivalent to a regular function call, and "metafunc" is
equivalent to boost::bind(func, args...)
These are exact analogies, AFAICT.
OK, that's what I thought, but it seems not to apply to
lambda-expressions. If I want to call foo<> on a placeholder
I don't know what you mean, but I'm pretty sure you don't mean what
you said. Nobody but the MPL internals want to actually invoke
metafunctions on placeholders. Very often that will cause an error,
because the placeholder does not meet the expectations of the
metafunction for the type that is actually supposed to be passed to
it.
Let me put it like this: suppose I have some metaprogramming expression like
typename foo::type
Now suppose I want to apply this operation to a sequence of types,
rather than to baz, using transform<>. To do this, I need to convert
it to a lambda-expression to pass to transform<>. Intuitively, I would
expect this to be done by replacing baz with _1:
typename foo::type >::type
But this doesn't compile for the reasons you explain. You seem to be
telling me to eliminate the typename...::type on metafunction calls
that contain actual placeholders as arguments (and in practice this
seems to work), which leads to:
typename foo >::type
I take it that's correct? If so, suppose now that I have another piece of code:
typename foo::type
In other words, "apply foo to the nullary metafunction bar<baz>". Now
suppose again that I want to turn this into an equivalent
lambda-expression. Intuitively, I would again expect to do this by
substituting _1 for baz:
typename foo >::type.
However, this is identical to the lambda-expression for my first
example, which has different semantics, so one of the two must be
wrong. Which is wrong, and how can I fix it?
Thanks for all your help, by the way. I'm being a bit stubborn about
this because I want to make sure I really know what's going on here.