[mpl] Trivial metafunctions and placeholders don't mix ?

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 = = = = = = = = = = = = = = = = = = = = = = = = =

AMDG jean-louis.a.leroy@fortis.com 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
participants (2)
-
jean-louis.a.leroy@fortis.com
-
Steven Watanabe