On Thursday 30 April 2009 19:19:31 you wrote:
> When I try to specify the capture it works ((&sum, &f) works too but f is
> const):
>
> #include <algorithm>
>
> int
> main(void)
> {
> int numbers[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
> const std::size_t nn = sizeof(numbers)/sizeof(int);
> int sum = 0;
> int f = 5;
>
> //std::for_each(&numbers[0], &numbers[nn], [&](int n) { sum += n * f; });
>
> std::for_each(&numbers[0], &numbers[nn], [&sum, f](int n) { sum += n * f;
> });
>
> return 0;
> }
Yup. In fact, almost any other capture block than the [&] works :) I will try
to look at those tree options when I get sober again.
--
Kind regards, Esben