
On 4/3/2012 2:45 AM, paul Fultz wrote:
push_back is designed to be non-mutating. That is why. This is true of all the views returned from 'algos', by design. What you can do is to make a container from the view through, e.g. as_vector, as_list. It is *not* true that all sequences return const refs to its elements. Containers definitely return references, otherwise get<N>(c)= expr will not be possible.
Also, front and back return non-const reference, but thats not the point. During iteration, they return const reference. Thats why this is not possible:
struct mutable_func { template<class F> struct result;
template
struct result { typedef T type; }; template
T operator()(T && x, U y) const { return x+=y; } }; int i = 0; invoke(foo, tuple
(i, 1)); //doesn't compile here is the output:
What is 'foo'? Anyway, this (below) compiles fine with me with
g++ 4.6.1 and MSVC 10:
#include