
Hi Eric, Eric Niebler schrieb:
You're not missing anything. Proto handle operator() differently than the other operators: operator() captures its arguments by const ref, whereas the other operators have overloads for const and non-const ref. Why the difference? Because operator() can have up to BOOST_PROTO_MAX_FUNCTION_CALL_ARITY arguments, which defaults to 5. To accomodate every permutation of const and non-const arguments would require 2^5 + 2^4 + 2^3 + 2^2 + 2^1 + 2^0 overloads, which is ... a lot. 2^6-1=63 is very a lot.
So what are your options. my suggestion is to first change this:
boost::result_of
::type & result = Rhs()(expr); to more correct:
boost::result_of
::type result = Rhs()(expr);
Ok, this i understand.
Now, if you are certain that the result is really a mutable lvalue, you can const_cast the result to a std::vector<int>& and mutate it.
The alternative would be to make _o_ an expression extension with overloads of operator() to handle all the permutations. Thanks for your advice.
Best regards, Kim