This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: iter_swapping vector<bool>::iterator..


Chris Jefferson wrote:

Sorry, I'll provide a bit more detail this time!

Thanks and sorry about my harsh reply: I become *very* nervous when I snif regressions...

The problem is that vector<bool>::iterator returns a temporary
_Bit_Reference rather than a "proper" reference. If iter_swap is defined as:


void iter_swap(A a,B b) { swap(*a,*b); }

then as swap is defined as "void swap(T& t,U &u);", then you get the error:

invalid initialization of non-const reference of type
'std::_Bit_reference' from a temporary of type 'std::_Bit_reference'

Ok, got it.


According to my reading of the standard, the new behaviour is correct as
according to Table 47, a forward iterator must for "*a" return "T&", and
iter_swap only claims to work on forward iterators.

Table 74, got it...


Vector<bool> isn't a
proper container and it's iterators don't satisfy the conditions for
forward iterators.

This is not at all *obvious*. I understand what you mean by "isn't a proper container",
this a *well* known issue, in general. The *specific* issue, new to me, is that its
iterators don't satisfy the forward iterator requirements. Therefore, I agree that we
are entitled to not iter_swap those iterators. Still, I'm not sure if users understand
this *long standing* issue with (our implementation) of vector<bool>::iterator. Also,
I'm not sure whether this is actually a bug of our implementation of vector<bool>.


What do other people think?

In short, my current position is that would be stupid reverting the iter_swap changes
because of this, but maybe we should document the behavior somehow or even
reconsider our implementation of vector<bool>::iterator itself.


Anyone knows whether other implementors are able to provide a vector<bool>::iterator
which meets the forward iterator requirements? Everything really boils down to this,
in my opinion.


Paolo.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]