[PATCH] Implement resolution of LWG DR 685 precisely

Jonathan Wakely jwakely@redhat.com
Tue Aug 23 12:23:00 GMT 2016


On 23/08/16 11:19 +0100, Jonathan Wakely wrote:
>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.

For gcc-5 and gcc-6 I'm making this smaller change that retains the
non-standard overload, but constrains it so it's SFINAE-friendly.

Tested x86_64-linux, committed to gcc-5-branch and gcc-6-branch.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.txt
Type: text/x-patch
Size: 2746 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20160823/fc6a5ef1/attachment.bin>


More information about the Libstdc++ mailing list