|
Boost Users : |
From: Jaakko Jarvi (jajarvi_at_[hidden])
Date: 2003-07-04 13:34:36
In our last exciting episode "Matt Hurd" wrote:
> That was quick. Thanks.
Don't mention.
> for_each(v.begin(), v.end(), _1 = bind(gen_long));
> Yep, that's how I originally had it. Generates lots of compile errors
> with GCC 3.2 (mingw).
> Any clues?
There seems to be two things. First, LL can't deduce the return type
of gen_long() call. That is a bit odd, as the class seems to define
result_type, which should be enough. Anyway, that can be fixed with
bind<long>(gen_long)
Then your gen_long is a stateful object, and the operator() is not
defined as const. Lambda functors store all arguments by default
as const copies. You must thus tell the library to store a
reference to your original function object:
bind<long>(ref(gen_long))
var does just as well:
bind<long>(var(gen_long))
Cheers, Jaakko
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net