|
Boost : |
From: Daniel Wallin (dalwan01_at_[hidden])
Date: 2004-06-16 06:29:05
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));
-- Daniel Wallin
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk