Boost logo

Boost :

From: Aleksey Gurtovoy (agurtovoy_at_[hidden])
Date: 2002-11-27 19:52:47


David B. Held wrote:
> In this code,
>
> template <class F, typename T>
> struct apply_lambda
> {
> typedef typename mpl::lambda<F>::type f_;
> typedef typename mpl::apply<f_, T>::type type;
> };
>
> MSVC reports that there is no "apply" in "mpl". I thought
> it was being stupid, so I preprocessed the source, and
> verified that sure enough there *is* no apply in mpl.

That's correct (see lines 58-62 in "boost/mpl/apply.hpp"). One have to use
the numbered forms, and it's a recommended practice for writing portable MPL
code. The same with 'bind' (for slightly different reasons, but still).

> I discovered that apply1 works just fine, however. I assume
> that MSVC can't handle the full apply<> machinery,

It can, but it doesn't like the name clash between top-level 'apply'
template and nested 'apply'-s inside metafunction classes:

    template< typename F, typename T >
    struct apply
    {
        typedef T type;
    };

    struct her
    {
        template< typename T > struct apply // ICE here
        {
            typedef T type;
        };
    };

Renaming top-level 'apply' to something else (e.g. 'apply_') resolves the
conflict, but IMO it's not worth it - you can use the appropriate numbered
form to the same effect.

> but is this documented?

Now it is :). Speaking seriously, it's on my documentation to-do list.

Aleksey


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