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: N3644 Comparing value-initialized iterators


On 25 November 2013 21:35, François Dumont wrote:
> Ok, N3644 is for C++14 ?

Yes.

> However there are already checks like:
>
>      // _GLIBCXX_RESOLVE_LIB_DEFECTS
>      // DR 408. Is vector<reverse_iterator<char*> > forbidden?
>     _GLIBCXX_DEBUG_VERIFY(!__x._M_singular()
>                   || __x._M_current == _Iterator(),
>                    _M_message(__msg_copy_singular)
>                    ._M_iterator(*this, "this")
>                    ._M_iterator(__x, "other"));
>
>     According comment it looks like it is especially targetting built-in
> types like pointers. But for other iterator types it looks like an undefined
> behavior, we might miss invalid usage because of it, no ?

The DR means it is OK to copy value-initialized iterators.

The check above relies on the fact we can compare value-initialized
iterators, which is not actually safe before C++14!  (Although IIRC
part of the point of N3644 was that in practice comparing two
value-init'd ForwardIterators usually has well-defined semantics).

>     By the way, N3644 is only for == and != operators or also for ordering
> ones like < ?

For any comparisons, but you can only compare value-initialized
iterators to other value-initialized iterators.

> I guess it is not for operator-, right ?

That's not a comparison :-)


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