#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <functional>
#include <deque>
using namespace std;
#include <tr1/functional>
using namespace std::tr1::placeholders;
template<class Function_t>
void for_each_x(Function_t func,int interval)
{
for(int sc = 0; sc < 10; sc+=interval){
func((const int)sc);
}
}
void foo(int x,const int y)
{
}
int main(int argc, char *argv[])
{
for_each_x(tr1::bind(tr1::function<void(int,const int)>(foo),_1,11),2);
return 0;
}
gcc 4.2.2 or 4.4.1 gives very long error message. if I change the "const int" to "int", then no error message. But I really like to have the "const int" to make sure the counter variable doesn't changed by accident if the function's argument is passed by reference.