I am trying to use boost::fusion::vector. However, I am in trouble with the very simple problem.
#include <iostream>
#include <string>
#include <boost/fusion/container/vector.hpp>
#include <boost/fusion/algorithm.hpp>
using namespace std;
struct A{
template <class T>
void operator()(const T& t) {
x++;
cout << t << endl;
}
int x = 0;
};
int main(){
A a;
boost::fusion::vector<int, int, int> tuple{3,4,5};
boost::fusion::for_each(tuple, a);
}
Note that the operator()
of struct A
modifies x
in struct A
.
gcc 4.7.2 warns that ...\include\boost\fusion\algorithm\iteration\detail\for_each.hpp:77: error: passing 'const A' as 'this' argument of 'void A::operator()(const T&) [with T = int]' discards qualifiers [-fpermissive]
Is there a solution for this?