Commit Graph

9557 Commits

Author SHA1 Message Date
Patrick Palka
76a8c0f65e libstdc++: LWG 3397 basic_istream_view::iterator should not provide iterator_category
libstdc++-v3/ChangeLog:

	LWG 3397 basic_istream_view::iterator should not provide
	iterator_category
	* include/std/ranges (basic_istream_view:_Iterator::iterator_category):
	Rename to ...
	(basic_istream_view:_Iterator::iterator_concept): ... this.
	* testsuite/std/ranges/istream_view.cc: Augment test.
2020-02-25 13:04:33 -05:00
Patrick Palka
ec15da7c33 libstdc++: LWG 3325 Constrain return type of transformation function for transform_view
libstdc++-v3/ChangeLog:

	LWG 3325 Constrain return type of transformation function for
	transform_view
	* include/std/ranges (transform_view): Constrain the return type of the
	transformation function as per LWG 3325.
	* testsuite/std/ranges/adaptors/lwg3325_neg.cc: New test.
2020-02-25 13:04:32 -05:00
Patrick Palka
55c4b3f486 libstdc++: LWG 3313 join_view::iterator::operator-- is incorrectly constrained
libstdc++-v3/ChangeLog:

	LWG 3313 join_view::_Iterator::operator-- is incorrectly constrained
	* include/std/ranges (join_view::_Iterator::operator--): Require that
	range_reference_t<_Base> models common_range.
	* testsuite/std/ranges/adaptors/lwg3313_neg.cc: New test.
2020-02-25 13:04:32 -05:00
Patrick Palka
510bd1c178 libstdc++: LWG 3301 transform_view::iterator has incorrect iterator_category
libstdc++-v3/ChangeLog:

	LWG 3301 transform_view::_Iterator has incorrect iterator_category
	* include/std/ranges (transform_view::_Iterator::_S_iter_cat): Adjust
	determination of iterator_category as per LWG 3301.
	* testsuite/std/ranges/adaptors/transform.cc: Augment test.
2020-02-25 13:04:32 -05:00
Patrick Palka
7f0f108309 libstdc++: LWG 3292 iota_view is under-constrained
libstdc++-v3/ChangeLog:

	LWG 3292 iota_view is under-constrained
	* include/std/ranges (iota_view): Require that _Winc models semiregular
	  as per LWG 3292.
	* testsuite/std/ranges/iota/lwg3292_neg.cc: New test.
2020-02-25 12:39:51 -05:00
Jonathan Wakely
490350a11f libstdc++: Remove __memmove wrapper for constexpr algorithms
The mutating sequence algorithms std::copy, std::copy_backward,
std::move and std::move_backward conditionally use __builtin_memmove
for trivially copyable types. However, because memmove isn't usable in
constant expressions the use of __builtin_memmove is wrapped in a
__memmove function which replaces __builtin_memmove with a handwritten
loop when std::is_constant_evaluated() is true.

This means we have a manual loop for non-trivially copyable cases, and a
different manual loop for trivially copyable but constexpr cases. The
latter loop has incorrect semantics for the {copy,move}_backward cases
and so isn't used for them. Until earlier today the latter loop also had
incorrect semantics for the std::move cases, trying to move from const
rvalues.

The approach taken by this patch is to remove the __memmove function
entirely and use the original (and correct) manual loops for the
constexpr cases as well as the non-trivially copyable cases. This was
already done for move_backward and copy_backward, but was incorrectly
turning copy_backward into move_backward, by failing to use the _IsMove
constant to select the right specialization. This patch also fixes that.

	* include/bits/ranges_algobase.h (__copy_or_move): Do not use memmove
	during constant evaluation. Call __builtin_memmove directly instead of
	__memmove.
	(__copy_or_move_backward): Likewise.
	* include/bits/stl_algobase.h (__memmove): Remove.
	(__copy_move<M, true, random_access_iterator_tag>::__copy_m)
	(__copy_move_backward<M, true, random_access_iterator_tag>::__copy_m):
	Use __builtin_memmove directly instead of __memmove.
	(__copy_move_a2): Do not use memmove during constant evaluation.
	(__copy_move_backward_a2): Use _IsMove constant to select correct
	__copy_move_backward specialization.
	* testsuite/25_algorithms/copy_backward/constexpr.cc: Check for copies
	begin turned into moves during constant evaluation.
2020-02-25 17:01:50 +00:00
Jonathan Wakely
dfb93d0524 Fix ChangeLog date 2020-02-25 16:58:52 +00:00
Jonathan Wakely
6de946e65c libstdc++: Add test accidentally left out of previous commit
* testsuite/25_algorithms/move_backward/93872.cc: Add test left out of
	previous commit.
2020-02-25 12:42:03 +00:00
Jonathan Wakely
5b904f175f libstdc++: Fix regression in std::move algorithm (PR 93872)
The std::move and std::move_backward algorithms dispatch to the
std::__memmove helper when appropriate. That function uses a
pointer-to-const for the source values, preventing them from being
moved. The two callers of that function have the same problem.

Rather than altering __memmove and its callers to work with const or
non-const source pointers, this takes a more conservative approach of
casting away the const at the point where we want to do a move
assignment. This relies on the fact that we only use __memmove when the
type is trivially copyable, so we know the move assignment doesn't alter
the source anyway.

	PR libstdc++/93872
	* include/bits/stl_algobase.h (__memmove): Cast away const before
	doing move assignment.
	* testsuite/25_algorithms/move/93872.cc: New test.
	* testsuite/25_algorithms/move_backward/93872.cc: New test.
2020-02-25 12:21:44 +00:00
Patrick Palka
85c143d002 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.
2020-02-24 10:09:52 -05:00
Patrick Palka
c5eab4ed45 libstdc++: P0769R2 Add shift to <algorithm>
This patch adds std::shift_left and std::shift_right as per P0769R2.  Alhough
these are STL-style algos, this patch places them in <bits/ranges_algo.h>
because they make use of some functions in the ranges namespace that are more
easily reachable from <bits/ranges_algo.h> than from <bits/stl_algo.h>, namely
ranges::next.  In order to place these algos in <bits/stl_algo.h>, we would need
to include <bits/range_access.h> from <bits/stl_algo.h> which would undesirably
increase the size of <bits/stl_algo.h>.

libstdc++-v3/ChangeLog:

	P0769R2 Add shift to <algorithm>
	* include/bits/ranges_algo.h (shift_left, shift_right): New.
	* testsuite/25_algorithms/shift_left/1.cc: New test.
	* testsuite/25_algorithms/shift_right/1.cc: New test.
2020-02-24 10:08:57 -05:00
Jonathan Wakely
8566286eae libstdc++: Fix noexcept-specifier for istream_iterator
Somehow I missed that the _M_value member can throw on construction.

	* include/bits/stream_iterator.h (istream_iterator(default_sentinel_t)):
	Make noexcept-specifier conditional.
	* testsuite/24_iterators/istream_iterator/cons/sentinel.cc: Check
	noexcept-specifier.
2020-02-24 14:22:21 +00:00
Jonathan Wakely
120e873484 libstdc++: Add default_sentinel support to stream iterators
Missing pieces of P0896R4 "The One Ranges Proposal" for C++20.

	* include/bits/stream_iterator.h (istream_iterator(default_sentinel_t)):
	Add constructor.
	(operator==(istream_iterator, default_sentinel_t)): Add operator.
	(ostream_iterator::difference_type): Define to ptrdiff_t for C++20.
	* include/bits/streambuf_iterator.h
	(istreambuf_iterator(default_sentinel_t)): Add constructor.
	(operator==(istreambuf_iterator, default_sentinel_t)): Add operator.
	* testsuite/24_iterators/istream_iterator/cons/sentinel.cc:
	New test.
	* testsuite/24_iterators/istream_iterator/sentinel.cc: New test.
	* testsuite/24_iterators/istreambuf_iterator/cons/sentinel.cc:
	New test.
	* testsuite/24_iterators/istreambuf_iterator/sentinel.cc: New test.
2020-02-24 13:39:18 +00:00
Jonathan Wakely
3841739c29 libstdc++: enable_view has false positives (LWG 3326)
* include/std/ranges (__deep_const_range, __enable_view_impl): Remove.
	(ranges::enable_view): Simplify (LWG 3326).
	* include/bits/range_access.h (ranges::enable_view): Declare.
	* include/bits/regex.h (__enable_view_impl): Remove partial
	specialization.
	* include/bits/stl_multiset.h (__enable_view_impl): Likewise.
	* include/bits/stl_set.h (__enable_view_impl): Likewise.
	* include/bits/unordered_set.h (__enable_view_impl): Likewise.
	* include/debug/multiset.h (__enable_view_impl): Likewise.
	* include/debug/set.h (__enable_view_impl): Likewise.
	* include/debug/unordered_set (__enable_view_impl): Likewise.
	* include/experimental/string_view (ranges::enable_view): Define
	partial specialization.
	* include/std/span (ranges::enable_view): Likewise.
	* include/std/string_view (ranges::enable_view): Likewise.
	* testsuite/std/ranges/view.cc: Check satisfaction of updated concept.
2020-02-24 12:15:05 +00:00
Jonathan Wakely
9e58988061 libstdc++: Define <=> for tuple, optional and variant
Another piece of P1614R2.

	* include/std/optional (operator<=>(optional<T>, optional<U>))
	(operator<=>(optional<T>, nullopt), operator<=>(optional<T>, U)):
	Define for C++20.
	* include/std/tuple (__tuple_cmp): New helper function for <=>.
	(operator<=>(tuple<T...>, tuple<U>...)): Define for C++20.
	* include/std/variant (operator<=>(variant<T...>, variant<T...>))
	(operator<=>(monostate, monostate)): Define for C++20.
	* testsuite/20_util/optional/relops/three_way.cc: New test.
	* testsuite/20_util/tuple/comparison_operators/three_way.cc: New test.
	* testsuite/20_util/variant/89851.cc: Move to ...
	* testsuite/20_util/variant/relops/89851.cc: ... here.
	* testsuite/20_util/variant/90008.cc: Move to ...
	* testsuite/20_util/variant/relops/90008.cc: ... here.
	* testsuite/20_util/variant/relops/three_way.cc: New test.
2020-02-21 17:12:39 +00:00
Patrick Palka
6e63438a0d libstdc++: Fix capturing of lvalue references in_RangeAdaptor::operator()
This fixes a dangling-reference issue with views::split and other multi-argument
adaptors that may take its extra arguments by reference.

When creating the _RangeAdaptorClosure in _RangeAdaptor::operator(), we
currently capture all provided arguments by value.  When we then use the
_RangeAdaptorClosure and call it with a range, as in e.g.

    v = views::split(p)(range),

we forward the range and the captures to the underlying adaptor routine.  But
then when the temporary _RangeAdaptorClosure goes out of scope, the by-value
captures get destroyed and the references to these captures in the resulting view
become dangling.

This patch fixes this problem by capturing lvalue references by reference in
_RangeAdaptorClosure::operator(), and then forwarding the captures appropriately
to the underlying adaptor routine.

libstdc++-v3/ChangeLog:

	* include/std/ranges (views::__adaptor::__maybe_refwrap): New utility
	function.
	(views::__adaptor::_RangeAdaptor::operator()): Add comments.  Use
	__maybe_refwrap to capture lvalue references by reference, and then use
	unwrap_reference_t to forward the by-reference captures as references.
	* testsuite/std/ranges/adaptors/split.cc: Augment test.
	* testsuite/std/ranges/adaptors/split_neg.cc: New test.
2020-02-20 14:06:23 -05:00
Patrick Palka
5586e5060f libstdc++: Forward second argument of views::iota using the correct type
We are forwarding the second argument of views::iota using the wrong type,
causing compile errors when calling views::iota with a value and bound of
different types, like in the test case below.

libstdc++-v3/ChangeLog:

	* include/std/ranges (iota_view): Forward declare _Sentinel.
	(iota_view::_Iterator): Befriend _Sentinel.
	(iota_view::_Sentinel::_M_equal): New member function.
	(iota_view::_Sentinel::operator==): Use it.
	(views::_Iota::operator()): Forward __f using the correct type.
	* testsuite/std/ranges/access/ssize.cc (test06): Don't call views::iota
	with integers of different signedness, to appease iota_view's deduction
	guide.
	* testsuite/std/ranges/iota/iota_view.cc: Augment test.
2020-02-20 13:54:43 -05:00
Jonathan Wakely
e817c23f68 libstdc++: Issues with range access CPOs (P2091R0)
This changes how arrays of unknown bound and/or incomplete element type
are handled.

	* include/bits/range_access.h (ranges::begin): Reject array of
	incomplete type.
	(ranges::end, ranges::size): Require arrays to be bounded.
	(ranges::data): Require lvalue or borrowed_range.
	(ranges::iterator_t): Remove constraint.
	* testsuite/std/ranges/access/begin.cc: Do not check array of
	incomplete type.
	* testsuite/std/ranges/access/begin_neg.cc: New test.
	* testsuite/std/ranges/access/end_neg.cc: Adjust expected error.
	* testsuite/std/ranges/access/size_neg.cc: Adjust expected error.
	* testsuite/std/ranges/access/ssize.cc: Do not check array of
	incomplete type.
2020-02-20 13:22:29 +00:00
Jonathan Wakely
4be779f59b libstdc++: Define operator<=> for <system_error> types
Another piece of P1614R2 for C++20.

This also adds tests for operator< in C++11, which was present but
untested.

	* include/std/system_error (error_category::operator<=>)
	(operator<=>(const error_code&, const error_code&))
	(operator<=>(const error_condition&, const error_condition&)): Define
	for C++20.
	* testsuite/19_diagnostics/error_category/operators/less.cc: New test.
	* testsuite/19_diagnostics/error_category/operators/three_way.cc: New
	test.
	* testsuite/19_diagnostics/error_code/operators/equal.cc: Remove
	incorrect comment.
	* testsuite/19_diagnostics/error_code/operators/less.cc: New test.
	* testsuite/19_diagnostics/error_code/operators/not_equal.cc: Remove
	incorrect comment.
	* testsuite/19_diagnostics/error_code/operators/three_way.cc: New test.
	* testsuite/19_diagnostics/error_condition/operators/equal.cc: Remove
	incorrect comment.
	* testsuite/19_diagnostics/error_condition/operators/less.cc: New test.
	* testsuite/19_diagnostics/error_condition/operators/not_equal.cc:
	Remove incorrect comment.
	* testsuite/19_diagnostics/error_condition/operators/three_way.cc: New
	test.
2020-02-20 12:27:48 +00:00
Jonathan Wakely
20fa41e61f libstdc++: Remove std::type_info::operator!= for C++20
This function can be synthesized by the compiler now.

	* libsupc++/typeinfo (type_info::operator!=): Remove for C++20.
2020-02-20 11:30:19 +00:00
Jonathan Wakely
c7b591f386 libstdc++: Add <=> to thread::id
* include/std/thread (thread:🆔:operator<=>): Define for C++20.
	* testsuite/30_threads/thread/id/70294.cc: Do not take addresses of
	functions in namespace std.
	* testsuite/30_threads/thread/id/operators_c++20.cc: New test.
2020-02-20 11:30:19 +00:00
Patrick Palka
38c7b74d2e libstdc++: Add missing call to unused subroutine in split_view test
libstdc++-v3/ChangeLog:

	* testsuite/std/ranges/adaptors/split.cc (test03): Don't include the
	null terminator of the underlying string as part of the test_range.
	(main): Call test03.
2020-02-19 17:15:19 -05:00
Jonathan Wakely
1b425f3ac5 libstdc++: make common_iterator<I, S> require copyable<I> (LWG 3385)
* include/bits/stl_iterator.h (common_iterator): Add copyable<I>
	requirement (LWG 3385).
	* testsuite/24_iterators/headers/iterator/synopsis_c++20.cc: Adjust
	expected declaration.
2020-02-19 22:11:27 +00:00
Jonathan Wakely
7433536b3d libstdc++: Add default-initializers to views (LWG 3364)
* include/std/ranges (take_while_view, drop_view, drop_while_view)
	(elements_view:_Iterator): Initialize data members (LWG 3364).
2020-02-19 22:10:41 +00:00
Jonathan Wakely
256f67aa07 libstdc++: Simplify std::three_way_comparable_with (LWG 3360)
This also removes a useless condition that was supposed to be removed by
the P1959R0 changes, but left in when that was implemented.

	* libsupc++/compare (three_way_comparable): Remove always-false check
	that should have been removed with weak_equality (P1959R0).
	(three_way_comparable_with): Likewise. Reorder requirements (LWG 3360).
2020-02-19 21:49:24 +00:00
Jonathan Wakely
0294dc5f4e libstdc++: Simplify std::totally_ordered (LWG 3331)
* include/std/concepts (__detail::__partially_ordered_with): Move here
	from <compare>.
	(totally_ordered, totally_ordered_with): Use __partially_ordered_with
	to simplify definition (LWG 3331).
	* libsupc++/compare (__detail::__partially_ordered_with): Move to
	<concepts>.
2020-02-19 21:40:03 +00:00
Jonathan Wakely
241ed96550 libstdc++: Simplify std::totally_ordered_with (LWG 3329)
* include/std/concepts (totally_ordered_with): Remove redundant
	requirement (LWG 3329).
2020-02-19 21:31:06 +00:00
Jonathan Wakely
77f5310f02 libstdc++: subrange converting constructor should disallow slicing (LWG 3282)
* include/std/ranges (__detail::__convertible_to_non_slicing): New
	helper concept.
	(__detail::__pair_like_convertible_to): Remove.
	(__detail::__pair_like_convertible_from): Add requirements for
	non-slicing conversions.
	(subrange): Constrain constructors with __convertible_to_non_slicing.
	Remove constructors from pair-like types. Add new deduction guide.
	* testsuite/std/ranges/subrange/lwg3282_neg.cc: New test.
2020-02-19 21:21:06 +00:00
Jonathan Wakely
59aa9e577e libstdc++: ranges::iter_move should perform ADL-only lookup (LWG 3247)
* include/bits/iterator_concepts.h (iter_move): Add declaration to
	prevent unqualified lookup finding a suitable declaration (LWG 3247).
2020-02-19 21:21:06 +00:00
Jonathan Wakely
e89100ef2e libstdc++: make polymorphic_allocator throw consistent type (LWG 3237)
* include/std/memory_resource (polymorphic_allocator::allocate)
	(polymorphic_allocator::allocate_object): Change type of exception to
	bad_array_new_length (LWG 3237).
	* testsuite/20_util/polymorphic_allocator/lwg3237.cc: New test.
2020-02-19 15:34:08 +00:00
Jonathan Wakely
bb54e0b879 libstdc++: Add __cpp_lib_unwrap_ref feature test macro
We already defined the traits in <type_traits> as now required by LWG
3348, but the macro was missing. This adds it.

	* include/std/type_traits (__cpp_lib_unwrap_ref): Define (LWG 3348).
	* include/std/version (__cpp_lib_unwrap_ref): Likewise.
	* testsuite/20_util/unwrap_reference/1.cc: Check macro.
	* testsuite/20_util/unwrap_reference/3.cc: New test.
2020-02-19 15:28:54 +00:00
Jonathan Wakely
5f031f9747 libstdc++: midpoint should not constrain T is complete (LWG 3200)
* include/std/numeric (midpoint(T8, T*)): Do not check for complete
	type during overload resolution, use static assert instead (LWG 3200).
	* testsuite/26_numerics/midpoint/pointer.cc: Do not test with
	incomplete type.
	* testsuite/26_numerics/midpoint/pointer_neg.cc: New test.
2020-02-19 15:28:45 +00:00
Jonathan Wakely
66ae31eb30 libstdc++: span's deduction-guide for built-in arrays doesn't work (LWG 3369)
The 23_containers/span/deduction.cc test was already passing, but only
because I had previously implemented the original proposed resolution of
3255. As pointed out in 3255 that original P/R was incorrect because it
broke construction from array xvalues. This reverts the incorrect part
of 3255 (and adds tests for the case it broke), and implements the
resolution of 3369 instead.

	* include/std/span (span(T (&)[N])): Use non-deduced context to
	prevent first parameter from interfering with class template argument
	deduction (LWG 3369).
	* testsuite/23_containers/span/deduction.cc: Add missing 'const'.
	* testsuite/23_containers/span/lwg3255.cc: Check for construction from
	rvalues.
2020-02-19 15:28:33 +00:00
Jonathan Wakely
247f410b83 libstdc++: Remove std::span::cbegin and std::span::cend (LWG 3320)
* include/std/span (span::const_iterator, span::const_reverse_iterator)
	(span::cbegin(), span::cend(), span::crbegin(), span::crend()):
	Remove (LWG 3320).
	* testsuite/23_containers/span/everything.cc: Replace uses of cbegin
	and cend.
	* testsuite/20_util/specialized_algorithms/destroy/constrained.cc:
	Likewise.
	* testsuite/20_util/specialized_algorithms/uninitialized_copy/
	constrained.cc: Likewise.
	* testsuite/20_util/specialized_algorithms/
	uninitialized_default_construct/constrained.cc: Likewise.
	* testsuite/20_util/specialized_algorithms/uninitialized_fill/
	constrained.cc: Likewise.
	* testsuite/20_util/specialized_algorithms/uninitialized_move/
	constrained.cc: Likewise.
	* testsuite/20_util/specialized_algorithms/
	uninitialized_value_construct/constrained.cc: Likewise.
2020-02-19 15:27:49 +00:00
Jonathan Wakely
aca60ecff3 libstdc++: Add ranges_size_t and rename all_view (LWG 3335)
* include/bits/range_access.h (range_size_t): Define alias template.
	* include/std/ranges (all_view): Rename to views::all_t (LWG 3335).
	* testsuite/std/ranges/adaptors/filter.cc: Adjust to new name.
2020-02-19 12:46:57 +00:00
Jonathan Wakely
4cc3b275d3 libstdc++: Remove converting constructors from views (LWG 3280)
* include/std/ranges (filter_view, transform_view, take_view)
	(join_view, split_view, reverse_view): Remove commented-out converting
	constructors (LWG 3280).
2020-02-19 12:46:57 +00:00
Jonathan Wakely
5f3641d0c4 libstdc++: uninitialized_construct_using_allocator should use construct_at (LWG 3321)
* include/std/memory (uninitialized_construct_using_allocator): Use
	std::construct_at (LWG 3321).
2020-02-19 12:46:57 +00:00
Jonathan Wakely
020a03eec7 libstdc++: Add nodiscard to polymorphic_allocator members (LWG 3304)
* include/std/memory_resource (polymorphic_allocator::allocate_bytes)
	(polymorphic_allocator::allocate_object)
	(polymorphic_allocator::new_object): Add nodiscard attribute (LWG3304).
2020-02-19 12:46:57 +00:00
Jonathan Wakely
15411a6453 libstdc++: "safe" in several library names is misleading (LWG 3379)
* include/bits/range_access.h (enable_safe_range): Rename to
	enable_borrowed_range.
	(__detail::__maybe_safe_range): Rename to __maybe_borrowed_range.
	(safe_range): Rename to borrowed_range.
	* include/bits/ranges_algo.h: Adjust to use new names.
	* include/bits/ranges_algobase.h: Likewise.
	* include/bits/ranges_uninitialized.h: Likewise.
	* include/std/ranges: Likewise.
	(safe_iterator_t): Rename to borrowed_iterator_t.
	(safe_subrange_t): Rename to borrowed_subrange_t.
	* include/std/span: Adjust to use new names.
	* include/std/string_view: Likewise.
	* include/experimental/string_view: Likewise.
	* testsuite/std/ranges/access/begin.cc: Likewise.
	* testsuite/std/ranges/access/cbegin.cc: Likewise.
	* testsuite/std/ranges/access/cdata.cc: Likewise.
	* testsuite/std/ranges/access/cend.cc: Likewise.
	* testsuite/std/ranges/access/crbegin.cc: Likewise.
	* testsuite/std/ranges/access/crend.cc: Likewise.
	* testsuite/std/ranges/access/data.cc: Likewise.
	* testsuite/std/ranges/access/end.cc: Likewise.
	* testsuite/std/ranges/access/rbegin.cc: Likewise.
	* testsuite/std/ranges/access/rend.cc: Likewise.
	* testsuite/std/ranges/safe_range.cc: Likewise.
	* testsuite/std/ranges/safe_range_types.cc: Likewise.
	* testsuite/util/testsuite_iterators.h: Likewise.
2020-02-19 12:46:57 +00:00
Jonathan Wakely
fa89adaa97 libstdc++: tuple_element_t is also wrong for const subrange (LWG 3398)
* include/std/ranges (tuple_element<0, const subrange<I, S, K>>)
	(tuple_element<1, const subrange<I, S, K>>): Add partial
	specializations (LWG 3398).
	* testsuite/std/ranges/subrange/tuple_like.cc: New test.
2020-02-19 12:46:57 +00:00
Jonathan Wakely
a45fb21a10 libstdc++: Remove redundant bool casts in ranges algorithms
Some of these casts were added by me the other day, but some were
already present. I think they are all redundant following the
introduction of the boolean-testable concept in P1964R2.

	* include/bits/ranges_algo.h (__find_fn, __find_first_of_fn)
	(__adjacent_find_fn, __remove_if_fn, __remove_copy_if_fn)
	(__unique_fn, __unique_copy_fn): Remove redundant conversions to bool.
2020-02-19 12:46:57 +00:00
Patrick Palka
242b4fb7f4 libstdc++: P1983R0 Wording for GB301, US296, US292, US291, and US283
Among other changes, P1983R0 resolves LWG 3278 in a different way, so this patch
also reverts the already-applied wording of LWG 3278.

The wording for US291 (the join_view::begin hunk) also required adding the
friend _Iterator<!_Const> to join_view::_Iterator.  This friend is needed so
that _Iterator's converting constructor can access the private members of an
_Iterator of the opposite constness.

The wording for US283 has already been applied it seems.

libstdc++-v3/ChangeLog:

	P1983R0 Wording for GB301, US296, US292, US291, and US283
	* include/std/ranges (filter_view::pred): New member function.
	(join_view::_Iterator::_Iterator): Remove now-redundant comment since
	P1983R0 fixes the highlighted issue in the same way.
	(join_view::_Iterator<_Const>): Add friend
	join_view::_Iterator<!_Const>.
	(join_view::_M_inner): Remove mutable specifier, effectively reverting
	the proposed wording changes of P3278.
	(join_view::begin): Refine the condition for when to return a const
	iterator.
	(split_view::_OuterIter::_OuterIter): Adjust constraints.
	* testsuite/std/ranges/adaptors/filter.cc: Test that filter_view::pred
	exists and works.
2020-02-18 23:21:55 -05:00
Jonathan Wakely
a5b213dda5 libstdc++: Fix compilation of <ranges> with Clang (PR 93818)
PR libstdc++/93818
	* include/std/ranges (_RangeAdaptor): Add deduction guide.
	(filter_view::_Iterator): Add alias _Vp_iter and use in place of
	iterator_t<_Vp>.
	(filter_view::_Iterator::_S_iter_cat()): Add 'typename'.
	(transform_view::_Iterator): Add alias _Base_iter and use in place of
	iterator_t<_Base>.
	(transform_view::_Iterator::_S_iter_cat()): Add 'typename'.
	(join_view::_Iterator): Add _Outer_iter and _Inner_iter aliases.
	(join_view::_Iterator::_S_iter_cat()): Add 'typename'.
	(split_view::_InnerIter::_S_iter_cat()): Likewise.
2020-02-18 23:34:10 +00:00
Jonathan Wakely
ce7b39d0fc libstdc++: Fix new tests that fail for ILP32 targets
* testsuite/20_util/integer_comparisons/equal.cc: Fix invalid
	assumption that long is wider than int.
	* testsuite/20_util/integer_comparisons/greater_equal.cc: Likewise.
	* testsuite/20_util/integer_comparisons/less.cc: Likewise.
	* testsuite/20_util/integer_comparisons/less_equal.cc: Likewise.
	* testsuite/20_util/integer_comparisons/not_equal.cc: Likewise.
2020-02-18 18:57:30 +00:00
Jonathan Wakely
9b8e2dea78 libstdc++: P1976R2 Fixed-size span construction from dynamic range
This includes fixes for first, last, as_bytes and as_writable_bytes
which were missing from the paper.

	* include/std/span (__cpp_lib_span): Update value.
	(span(It, size_type), span(It, End)): Make conditionally explicit. Add
	assertion.
	(span(R&&), span(const span<OType, OExtent>&)): Likewise and relax
	constraints.
	(span::first<Count>(), span::last<Count>()): Use explicit type in
	return statement.
	(as_bytes, as_writable_bytes): Likewise.
	* include/std/version (__cpp_lib_span): Update value.
	* testsuite/23_containers/span/1.cc: Check new value.
	* testsuite/23_containers/span/2.cc: Check new value.
	* testsuite/23_containers/span/explicit.cc: New test.
2020-02-18 17:43:36 +00:00
Jonathan Wakely
d6c9e37237 libstdc++: Fix and simplify constraints on std::span constructors
This makes the constraints consistent with the pre-Prague working paper.

	* include/std/span (span::__is_compatible_array): Simplify alias
	template by using requires-clause.
	(span::__is_compatible_ref): New alias template for constraining
	constructors.
	(span::__is_compatible_iterator, span::__is_compatible_range): Remove.
	(span(It, size_type), span(It, End)): Use __is_compatible_ref.
	(span(T(&)[N], span(array<T, N>&), span(const array<T, N>&)): Remove
	redundant parentheses.
	(span(R&&)): Add missing constraints.
2020-02-18 17:42:54 +00:00
Jonathan Wakely
f09f32427b libstdc++: Reorder declarations of std::span members
I find it easier to work with this class when the declarations match the
order in the C++2a working paper.

There's no need to use long, descriptive template parameter names like
_ContiguousIterator when the parameter is already constrained by the
std::contiguous_iterator concept. This is also consistent with the
naming conventions in the working paper.

	* include/std/span (span): Reorder members and rename template
	parameters to match declarations in the C++2a working paper.
2020-02-18 17:42:37 +00:00
Jonathan Wakely
f5b4dc3885 libstdc++: P2116R0 Remove tuple-like protocol support from fixed-extent span
Following this change it's no longer possible to use std::span with
structured bindings or with the tuple-like API. It will probably come
back for C++23 though.

	P2116R0 Remove tuple-like protocol support from fixed-extent span
	* include/std/span (get, tuple_size, tuple_element): Remove.
	* testsuite/23_containers/span/everything.cc: Remove checks for
	tuple-like API.
	* testsuite/23_containers/span/get_neg.cc: Remove.
	* testsuite/23_containers/span/tuple_element_dynamic_neg.cc: Remove.
	* testsuite/23_containers/span/tuple_element_oob_neg.cc: Remove.
	* testsuite/23_containers/span/tuple_size_neg.cc: Remove.
2020-02-18 17:41:57 +00:00
Patrick Palka
aa667c3f36 libstdc++: P2106R0 Alternative wording for GB315 and GB316
libstdc++-v3/ChangeLog:

	P2106R0 Alternative wording for GB315 and GB316
	* include/bits/ranges_algo.h (in_fun_result): New.
	(for_each_result, for_each_n_result): Change into an alias of
	in_fun_result.
	(in_in_result): New.
	(mismatch_result): Change into an alias of in_in_result.
	(copy_if_result): Change into an alias of in_out_result.
	(swap_ranges_result): Change into an alias of in_in_result.
	(unary_transform_result): Change into an alias of in_out_result.
	(in_in_out_result): New.
	(binary_transform_result): Change into an alias of in_in_out_result.
	(replace_copy_result, replace_copy_if_result, remove_copy_if_result,
	remove_copy_result, unique_copy_result, reverse_copy_result,
	rotate_copy_result, partial_sort_copy_result): Change into an alias of
	in_out_result.
	(in_out_out_result): New.
	(partition_copy_result, merge_result): Change into an alias of
	in_out_out_result.
	(set_union_result, set_intersection_result): Change into an alias of
	in_in_out_result.
	(set_difference_result): Change into an alias of in_out_result.
	(set_symmetric_difference): Change into an alias of in_in_out_result.
	(min_max_result): New.
	(minmax_result, minmax_element_result): Change into an alias of
	min_max_result.
	(in_found_result): New.
	(next_permutation_result, prev_permutation_result): Change into an alias
	of in_found_result.
	(__next_permutation_fn::operator(), __prev_permutation_fn::operator()):
	Adjust following changes to next_permutation_result and
	prev_permutation_result.
	* include/bits/ranges_algobase.h (in_out_result): New.
	(copy_result, move_result, move_backward_result, copy_backward_result,
	copy_n_result): Change into an alias of in_out_result.
	* include/bits/ranges_uninitialized.h (uninitialized_copy_result,
	uninitialized_copy_n_result, uninitialized_move_result,
	uninitialized_move_n_result): Likewise.
	* testsuite/25_algorithms/next_permutation/constrained.cc: Adjust uses of
	structured bindings.
	* testsuite/25_algorithms/prev_permutation/constrained.cc: Likewise.
2020-02-18 11:06:50 -05:00
Patrick Palka
f316994199 libstdc++: P1243R4 Rangify new algorithms
This adds rangified overloads for for_each_n, sample and clamp as per P1243R4.

libstdc++-v3/ChangeLog:

	P1243R4 Rangify new algorithms
	* include/bits/ranges_algo.h (for_each_n_result, __for_each_n_fn,
	for_each_n, __sample_fn, sample, __clamp_fn, clamp): New.
	* testsuite/25_algorithms/clamp/constrained.cc: New test.
	* testsuite/25_algorithms/for_each/constrained.cc: Augment test.
	* testsuite/25_algorithms/sample/constrained.cc: New test.
2020-02-18 11:06:49 -05:00