Boost logo

Boost :

From: Brock Peabody (brock.peabody_at_[hidden])
Date: 2006-02-15 13:02:31


> -----Original Message-----
> From: boost-bounces_at_[hidden]
[mailto:boost-bounces_at_[hidden]]
> On Behalf Of Me here
> Sent: Wednesday, February 15, 2006 10:24 AM
> To: boost_at_[hidden]
> Subject: [boost] Binding function call to an assignment

> I want to make a binder to do an assignment like:
>
> ------ example ------
> #include "boost/bind.hpp"
>
> int main()
> {
> int X = 0;
>
> boost::bind<int&>(X, _1)( 1 );
>
> return 0;
> }
> --- end ---

You could use lambda:

#include <boost/lambda/lambda.hpp>

int main()
{
  int X = 0;

  const int y = 1;

  namespace ll = boost::lambda;

 (ll::var(X) = ll::_1)(y)
 
  return 0;
}

Brock


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