Boost logo

Boost Users :

Subject: [Boost-users] [mpl] Trivial metafunctions and placeholders don't mix ?
From: jean-louis.a.leroy_at_[hidden]
Date: 2009-03-10 07:17:09


Hello.

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_<
        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
          mpl::push_back<
            mpl::second<mpl::_1>,
            _2
>::type
> // pair
>
>::type
> 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...

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?

Thanks,
Jean-Louis Leroy

= = = = = = = = = = = = = = = = = = = = = = = = =
Fortis disclaimer :
http://www.fortis.be/legal/disclaimer.htm

Privacy policy related to banking activities of Fortis:
http://www.fortis.be/legal/privacy_policy.htm
= = = = = = = = = = = = = = = = = = = = = = = = =


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