This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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]

[PATCH] Implement resolution of LWG DR 685 precisely


As Casey pointed out, our operator- overloads for reverse_iterator and
move_iterator are not conforming. For reverse_iterator the overload
taking a single template argument is not SFINAE friendly, and for
move_iterator it enables some expressions that aren't supposed to be
valid.

This removes the problematic operator- overloads for C++11 and later.
Anyone writing a greedy operator- in their own namespace should
constrain it to be less greedy.

(This matches what libc++ implements, and they don't seem to have a
problem with it).

Because the synopsis of <iterator> is so different in each standard
I've added multiple testcases for it.

	PR libstdc++/71771
	* include/bits/stl_iterator.h
	(operator-(reverse_iterator<Iter>, reverse_iterator<Iter>): Only
	define for C++98 mode.
	(operator-(move_iterator<Iter>, move_iterator<Iter>): Don't define.
	* testsuite/24_iterators/headers/iterator/synopsis.cc: Use
	-std=gnu++98.
	* testsuite/24_iterators/headers/iterator/synopsis_c++11.cc: New test.
	* testsuite/24_iterators/headers/iterator/synopsis_c++14.cc: New test.
	* testsuite/24_iterators/headers/iterator/synopsis_c++17.cc: New test.
	* testsuite/24_iterators/move_iterator/greedy_ops.cc: Don't test
	difference operator.
	* testsuite/24_iterators/reverse_iterator/greedy_ops.cc: Only test
	difference operator for C++98.
	* testsuite/24_iterators/reverse_iterator/71771.cc: New test.

Tested powerpc64le-linux, committed to trunk.


Attachment: patch.txt
Description: Text document


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