|
Boost Users : |
From: Tobias Schwinger (tschwinger_at_[hidden])
Date: 2007-03-20 12:34:57
David Abrahams wrote:
> on Sat Mar 17 2007, Tobias Schwinger <tschwinger-AT-isonews2.com> wrote:
>
>> The problem comes down to that MPL can't know where one placeholder
>> expression starts and where another one ends (denoted by uppercase
>> identifiers, above):
>
> There is an inherent limitation in that regard. These kinds of
> problems come up repeatedly, so Aleksey and I agree the library should
> provide a solution. We had a long discussion on the boost-devel list
> where we talked about the same issues in terms of runtime lambda
> expressions:
>
> http://lists.boost.org/Archives/boost/2005/01/78409.php
Oh, thanks!
Incidentally, I provided something very similar to 'outer' (discussed in
that thread) in the follow-up, called 'defer' (inspired by Chaos).
It's so easy, that it's almost provocative:
// returns an unspecified placeholder expression whose evaluation
// results in the original argument, no placeholder substitution
// applied
template<typename PlaceholderExpr>
struct defer
{
template<typename IgnoredPlaceholder> struct get
{
typedef PlaceholderExpr type;
};
typedef typename defer<PlaceholderExpr>::template get<_> type;
};
BOOST_MPL_ASSERT((
is_same<mpl::apply< defer<_1>::type ,int>::type, _1>
));
Of course it still needs "typename...type-clutter" in template context,
otherwise the lambda facility would have to be aware of its existence.
outer<_1> == typename defer<_1>::type
>
> As I said, this thread is long (it contains a whole thread attached to
> one message in the outer thread -- how appropriate!) but it's worth a
> read.
>
> Incidentally, protect<> doesn't help as it does something different.
Yes, namely nested binds - I figured that out, by now :-).
Regards,
Tobias
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net