I recently spent quite some time understanding the error message when calling func()
in this piece of code:
int main()
{
vector< vector&l
This isn't an answer, but I just want to record the modern C++11 solution, where all the small bind helpers are deprecated in favour of the universal std::bind
:
#include
#include
#include
void func(std::vector const & v, double * sum) { /* ... */ }
int main()
{
std::vector> v;
double sum = 0;
std::for_each(v.begin(), v.end(), std::bind(func, std::placeholders::_1, &sum));
}
The variadic templates of C++11, as well as a more comprehensive collection of type-modifying traits, give std::bind
much stronger deduction abilities than the previous components in
.