Boost Users :
From: David Abrahams (dave_at_[hidden])
Date: 2006-05-12 18:26:51
"Delfin Rojas" <drojas_at_[hidden]> writes:
>> Grisha Spivak wrote:
>> it = -22;
>> it = it;
>> std::cout << arr[2*2] << ' ' << arr[3*2] << ' ' <<
>> arr[5*2] << '\n';
>> It prints "-22 33 55" instead of "-22 55 55" (which I
>> expected) - so "it = it;" assignment didn't modifies array.
>> Is it intended behaviour? Or maybe I'm doing something wrong?
> If you change it = it; with it = 55; it will work. The problem is
> your iterator_facade::operator returns a
> boost::detail::operator_brackets_proxy which, I'm not sure why, does not
> seem to implement operator=(operator_brackets_proxy const &). There may be a
> good reason for this but perhaps the author(s) of the library can answer
We didn't think of it ;-)
explains why operator returns a proxy. You can write:
int x = it;
it = x;
to work around this problem.
Jeremy and Thomas: do you think we should change the
Mutable_RandomAccessIterator concept to require that
it[n] = e work
for any e convertible to the iterator's value_type?
-- Dave Abrahams Boost Consulting www.boost-consulting.com
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net