
16 Jun
2004
16 Jun
'04
11:47 a.m.
"Daniel Wallin" <dalwan01@student.umu.se> wrote in message news:capatv$p48$1@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