David Abrahams writes:
Aleksey Gurtovoy wrote:
Answering the OP question: MPL lambda expressions do not support scopes (yet), so it's not possible to implement the above without an auxiliary metafunction incapsulating the nested scope. Which actually might be a good thing -- it's hard to imagine that the "inline" version would be shorter and easier to understand than this:
template< typename Map, typename Entry > struct copy_entires : copy< typename Entry::second::entries , inserter
typedef fold
>::type result; In that case, can you explain what protect<> is for?
From http://www.boost.org/libs/mpl/doc/refmanual/protect.html:
'protect' is an identity wrapper for a Metafunction Class that
prevents its argument from being recognized as a bind expression.
Actually, the above definition is incomplete; should be:
'protect' is an identity wrapper for a Metafunction Class that
prevents its argument from being recognized as a bind/placeholder
expression.
The main usage for 'protect' is to prevent parametrized metafunction classes
from being accidentally treated as a placeholder expression simply because
their arguments happened to embed a placeholder. For instance:
template< typename Predicate > struct next_if
{
template< typename N, typename T >
struct apply
: eval_if<
typename apply1