|
Boost : |
From: Alberto Barbati (abarbati_at_[hidden])
Date: 2004-03-08 09:17:02
David Abrahams wrote:
> Alberto Barbati <abarbati_at_[hidden]> writes:
>
>>Problem is that there is something wrong with the implementation of
>>operator[] in iterator_facade and the regression test does not compile
>>anymore :-(
>
> What makes you say that there's something wrong with iterator_facade's
> operator[]? Is it possible that the regression test makes invalid
> assumptions about the way an iterator's operator[] is supposed to work?
The problem is triggered by the expression
BOOST_CHECK(it[0] == 2);
found in file base_test.cpp line 157. VC .NET 2003 gives the following
error message:
error C2678: binary '==' : no operator found which takes a left-hand
operand of type
'boost::detail::operator_brackets_result<Iterator,Value,Reference>::type'
(or there is no acceptable conversion)
with
[
Iterator=boost::cb_details::cb_iterator<boost::circular_buffer<Integer>,Integer>,
Value=Integer,
Reference=Integer &
]
"it" is defined as circular_buffer<Integer>::iterator. As the right hand
side is not an "Integer" I also tried writing:
BOOST_CHECK(it[0] == Integer(2));
but the error message stays the same.
>>However, if I hack iterator_facade::operator[] to avoid
>>the use of the operator_brackets_proxy class
>
> That's unneccessary. Any iterator_facade behavior you want to replace
> can simply be added to your derived iterator class.
Yes. Sure you are right. I feel kind of stupid, I should have thought
about it in the first place.
I am uploading a revised version of circular_buffer_new_iterators_v2.zip
that overrides operator[]. All regression tests passes with VC7.1. I
also made the implementation members private and fixed the comments.
Anyway you'll agree that the issue is quite general and it might be
interesting to investigate if we could find a solution at the
iterator_facade level.
>>all regression tests pass. Maybe it would be good to discuss this
>>problem of the iterator_facade in a different thread.
>
>
> Here we are!
:-)
Alberto
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk