$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [Boost-users] [mpl] Trivial metafunctions and placeholders don't mix ?
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2009-03-10 12:17:00
AMDG
jean-louis.a.leroy_at_[hidden] wrote:
> I'm trying to use a pair<> to pass values inside a fold<> :
>
> template<typename Seq>
> struct remove_duplicates // even if not consecutive; also keep order
> {
>   typedef typename mpl::second<
>     mpl::fold<
>       Seq,
>       mpl::pair< mpl::set<>, mpl::vector<> >,
>       typedef typename mpl::if_<
>   
typedef?
>         mpl::has_key<mpl::first<mpl::_1>, mpl::_2>,
>         mpl::_1,
>         mpl::pair<
>           typename mpl::insert<
>             mpl::first<mpl::_1>,
>             void,
>             mpl::_2
>           >::type, // insert
>   
Leave off the ::type.  It forces insert to be evaluated immediately, but
you want insert to be evaluated lazily.
>           mpl::push_back<
>             mpl::second<mpl::_1>,
>             _2
>           >::type
>   
Same thing here.
>         > // pair
>       >
>     >::type
>   
And yet again.
>   > type;
> };
>
> It looks like first<> and second<> don't work on placeholders. My compiler - Visual Studio 2008 - complains that "'first' : is not a member of 'boost::mpl::arg<1>". When I look at the definition of first<> I see a "BOOST_MPL_AUX_LAMBDA_SUPPORT(1,first,(P))" that should take care of placeholders I guess. But when I look at the definition of the macro, alas :
>
> #if !defined(BOOST_MPL_CFG_NO_FULL_LAMBDA_SUPPORT)
>
> #   define BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(i, name, params) /**/
> #   define BOOST_MPL_AUX_LAMBDA_SUPPORT(i,name,params) /**/
>
> What's the story here? My compiler is not good enough? Could be...
>   
Visual Studio 2008 doesn't have problems with lambda.
> While we're at it, should I put a BOOST_MPL_AUX_LAMBDA_SUPPORT(1,remove_duplicates,(P)) at the bottom of remove_duplicates<> ? Would it make my metafunction work with lambda placeholders?
>   
It should have no effect.
In Christ,
Steven Watanabe