ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> boost
boost
Re: [boost] MPL's "round" lambda
by =?iso-8859-1?Q?Terje_Sletteb=F8?= other posts by this author
Mar 11 2003 7:28AM messages near this date
[boost] MPL's "round" lambda | Re: [boost] MPL's "round" lambda
A few months ago, Aleksey posted a cool way of doing lambda using function
notation. I hadn't followed the thread at the time, but I read up on it
recently. Like many others, I found it hard to understand how it worked, so
I asked Aleksey if he could make a minimal example of it, which he did.

For the benefit of anybody else interested in knowing how it works, I post
the example here. I found it much easier to understand how it works, with
such a minimal example.

--- Start ---

#include <boost/mpl/quote.hpp> 
#include <boost/mpl/apply.hpp> 
#include "boost/mpl/bind.hpp"
#include "boost/type_traits/is_same.hpp"
#include "boost/static_assert.hpp"

using namespace boost::mpl;

template<typename T> 
struct expr
{
  typedef T type;
};

template<typename F, typename T1, typename T2> 
struct expr<F (T1, T2)>  : bind2<F, typename expr<T1>::type, typename
expr<T2> ::type> {};

struct is_same : quote2<boost::is_same>  {};

// Here:

typedef apply<expr<is_same(_, int)> , int>::type type;

BOOST_STATIC_ASSERT(type::value);

--- End ---


Regards,

Terje

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Thread:
Aleksey Gurtovoy
=?iso-8859-1?Q?Terje_Sletteb=F8?=
Joel de Guzman
Dirk Gerrits
Peter Dimov
Peter Dimov
Dirk Gerrits
Douglas Gregor
David Abrahams

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved