gcc/libstdc++-v3/testsuite/24_iterators
Patrick Palka 4b4f5666b4 libstdc++: Implement P2325 changes to default-constructibility of views
This implements the wording changes of P2325R3 "Views should not be
required to be default constructible".  Changes are relatively
straightforward, besides perhaps those to __box (which now stands
for copyable-box instead of semiregular-box) and __non_propagating_cache.

For __box, this patch implements the recommended practice to also avoid
std::optional when the boxed type is nothrow_move/copy_constructible.

For __non_propagating_cache, now that it's used by split_view::_M_current,
we need to add assignment from a value of the underlying type to the
subset of the std::optional API implemented for the cache (needed by
split_view::begin()).  Hence the new __non_propagating_cache::operator=
overload.

In passing, this fixes the undesirable list-init in the constructors of
the partial specialization of __box as reported in PR100475 comment #7.

libstdc++-v3/ChangeLog:

	* include/bits/iterator_concepts.h (weakly_incrementable): Remove
	default_initializable requirement.
	* include/bits/ranges_base.h (ranges::view): Likewise.
	* include/bits/ranges_util.h (subrange): Constrain the default
	ctor.
	* include/bits/stl_iterator.h (back_insert_iterator): Remove the
	default ctor.
	(front_insert_iterator): Likewise.
	(insert_iterator): Likewise.  Remove NSDMIs.
	(common_iterator): Constrain the default ctor.
	(counted_iterator): Likewise.
	* include/bits/stream_iterator.h (ostream_iterator): Remove the
	default ctor.
	* include/std/ranges (__detail::__box::operator=): Handle
	self-assignment in the primary template.
	(__detail::__box): In the partial specialization: adjust
	constraints as per P2325.  Add specialized operator= for the
	case when the wrapped type is not copyable.  Constrain the
	default ctor.  Avoid list-initialization.
	(single_view): Constraint the default ctor.
	(iota_view): Relax semiregular constraint to copyable.
	Constrain the default ctor.
	(iota_view::_Iterator): Constraint the default ctor.
	(basic_istream_view): Remove the default ctor.  Remove NSDMIs.
	Remove redundant checks for empty _M_stream.
	(basic_istream_view::_Iterator): Likewise.
	(ref_view): Remove the default ctor.  Remove NSDMIs.
	(ref_view::_Iterator): Constrain the default ctor.
	(__detail::__non_propagating_cache::operator=): Define overload
	for assigning from a value of the underlying type.
	(filter_view): Likewise.
	(filter_view::_Iterator): Likewise.
	(transform_view): Likewise.
	(transform_view::_Iterator): Likewise.
	(take_view): Likewise.
	(take_view::_Iterator): Likewise.
	(take_while_view): Likewise.
	(take_while_view::_Iterator): Likewise.
	(drop_while_view): Likewise.
	(drop_while_view::_Iterator): Likewise.
	(join_view): Likewise.
	(split_view::_OuterIter::__current): Adjust after changing the
	type of _M_current.
	(split_view::_M_current): Wrap it in a __non_propagating_cache.
	(split_view::split_view): Constrain the default ctor.
	(common_view): Constrain the default ctor.
	(reverse_view): Likewise.
	(elements_view): Likewise.
	* include/std/span (enable_view<span<_ElementType, _Extent>>):
	Define this partial specialization to true unconditionally.
	* include/std/version (__cpp_lib_ranges): Adjust value.
	* testsuite/24_iterators/back_insert_iterator/constexpr.cc:
	Don't attempt to default construct a back_insert_iterator.
	* testsuite/24_iterators/front_insert_iterator/constexpr.cc:
	Don't attempt to default construct a front_insert_iterator.
	* testsuite/24_iterators/insert_iterator/constexpr.cc:
	Don't attempt to default construct an insert_iterator.
	* testsuite/24_iterators/ostream_iterator/requirements/constexpr.cc:
	Remove this test for default constructibility of ostream_iterator.
	* testsuite/std/ranges/97600.cc: Don't attempt to default
	construct a basic_istream_view.
	* testsuite/std/ranges/adaptors/detail/semiregular_box.cc:
	Rename to ...
	* testsuite/std/ranges/adaptors/detail/copyable_box.cc: ... this.
	(test02): Adjust now that __box is copyable-box not
	semiregular-box.
	(test03): New test.
	* testsuite/std/ranges/p2325.cc: New test.
	* testsuite/std/ranges/single_view.cc (test06): New test.
	* testsuite/std/ranges/view.cc: Adjust now that view doesn't
	require default_initializable.
2021-06-17 22:29:03 -04:00
..
associated_types Update copyright years. 2021-01-04 10:26:59 +01:00
back_insert_iterator libstdc++: Implement P2325 changes to default-constructibility of views 2021-06-17 22:29:03 -04:00
bidirectional Update copyright years. 2021-01-04 10:26:59 +01:00
common_iterator Update copyright years. 2021-01-04 10:26:59 +01:00
contiguous Update copyright years. 2021-01-04 10:26:59 +01:00
counted_iterator Update copyright years. 2021-01-04 10:26:59 +01:00
customization_points libstdc++: Revert final/non-addressable changes to ranges CPOs 2021-06-16 14:31:04 +01:00
forward Update copyright years. 2021-01-04 10:26:59 +01:00
front_insert_iterator libstdc++: Implement P2325 changes to default-constructibility of views 2021-06-17 22:29:03 -04:00
headers/iterator libstdc++: Change [range.iter.op] functions to function objects [PR 100768] 2021-05-26 19:15:34 +01:00
indirect_callable Update copyright years. 2021-01-04 10:26:59 +01:00
input Update copyright years. 2021-01-04 10:26:59 +01:00
insert_iterator libstdc++: Implement P2325 changes to default-constructibility of views 2021-06-17 22:29:03 -04:00
istream_iterator Update copyright years. 2021-01-04 10:26:59 +01:00
istreambuf_iterator Update copyright years. 2021-01-04 10:26:59 +01:00
move_iterator libstdc++: Implement LWG 3391 changes to move/counted_iterator::base() 2021-05-06 09:11:42 -04:00
normal_iterator Update copyright years. 2021-01-04 10:26:59 +01:00
operations Update copyright years. 2021-01-04 10:26:59 +01:00
ostream_iterator libstdc++: Implement P2325 changes to default-constructibility of views 2021-06-17 22:29:03 -04:00
ostreambuf_iterator Update copyright years. 2021-01-04 10:26:59 +01:00
output Update copyright years. 2021-01-04 10:26:59 +01:00
random_access Update copyright years. 2021-01-04 10:26:59 +01:00
range_access libstdc++: Remove redundant -std=gnu++17 option from remaining tests 2021-05-10 16:22:54 +01:00
range_operations libstdc++: Fix return value of std::ranges::advance [PR 100833] 2021-06-01 17:09:06 +01:00
reverse_iterator libstdc++: Implement missing P0896R4 changes to reverse_iterator [PR100639] 2021-05-20 14:08:17 -04:00
aliases.cc Update copyright years. 2021-01-04 10:26:59 +01:00
container_access.cc libstdc++: Remove redundant -std=gnu++17 option from remaining tests 2021-05-10 16:22:54 +01:00