libstdc++: Add missing bits of P0896R4 pertaining to [back|front]_insert_iterator
authorPatrick Palka <ppalka@redhat.com>
Mon, 24 Feb 2020 12:59:08 +0000 (07:59 -0500)
committerPatrick Palka <ppalka@redhat.com>
Mon, 24 Feb 2020 15:09:52 +0000 (10:09 -0500)
commit85c143d002a31bebb675161315c8e62db240b636
treee3150cb35e03a6126eaf935bcf0020859f8f9eb5
parentc5eab4ed45e9762dfb8a58d2b5672d358467ad89
libstdc++: Add missing bits of P0896R4 pertaining to [back|front]_insert_iterator

This adds some missing pieces of the Ranges TS that make back_insert_iterator and
front_insert_iterator conform to the new output_iterator requirements.

It also fixes a bug in ranges::__copy_or_move and
ranges::__copy_or_move_backward in which we were inspecting the iter_value_t of
the output iterator, but output iterators such as back_insert_iterator and
front_insert_iterator whose value_type = void do not have an iter_value_t
according to [readable.traits] p4.  The entire __use_memmove condition should
probably be rewritten, but the simplest fix for now is to inspect the
iterator_traits of the output iterator instead.

libstdc++-v3/ChangeLog:

PR libstdc++/93884
* include/bits/ranges_algobase.h (__copy_or_move,
__copy_or_move_backward): Don't inspect the iter_value_t of the output
iterator, instead inspect its iterator_traits directly.
* include/bits/stl_iterator.h (back_insert_iterator::container):
Conditionally initialize.
(back_insert_iterator::difference_type): Conditionally define.
(back_insert_iterator::back_insert_iterator): Conditionally define this
default constructor.
(front_insert_iterator::container): Conditionally initialize.
(front_insert_iterator::difference_type): Conditionally define.
(front_insert_iterator::front_insert_iterator): Conditionally define
this default constructor.
* 24_iterators/back_insert_iterator/pr93884.cc: New test.
* 24_iterators/front_insert_iterator/pr93884.cc: New test.
libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/ranges_algobase.h
libstdc++-v3/include/bits/stl_iterator.h
libstdc++-v3/testsuite/24_iterators/back_insert_iterator/pr93884.cc [new file with mode: 0644]
libstdc++-v3/testsuite/24_iterators/front_insert_iterator/pr93884.cc [new file with mode: 0644]