Boost logo

Boost :

From: Jeff Flinn (TriumphSprint2000_at_[hidden])
Date: 2004-06-16 06:47:23


"Daniel Wallin" <dalwan01_at_[hidden]> wrote in message
news:capatv$p48$1_at_sea.gmane.org...
Lars Rune Nøstdal wrote:
> Hi,
> I'm a new user of this library, so not sure if this is a good idea or the
best way to do this.
>
>
> void f(int x)
> {
> cout << "f(int): " << x << endl;
> }
>
>
> int x = 0;
> bind(f, _1)(x);
> //bind(f, _1)(1); // Does not work.
> bind(f, _1)(val<int>(1)); // But this does after patching.
>
>
> This enables the user to pass-by-value if he specifies it explicitly, here
is the patch:

Or you can just do this:

   template<class T>
   T const& const_ref(T const& x)
   {
       return x;
   }

   bind(f, _1)(const_ref(1));

Won't this work?

    bind(f,_1)( boost::cref(1) );

Jeff Flinn


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