Commit Graph

11261 Commits

Author SHA1 Message Date
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
Jonathan Wakely
c5e1c1d3ab libstdc++: P1964R2 Wording for boolean-testable
This removes the complicated std::boolean concept, as agreed in Prague.

	* include/bits/ranges_algo.h (__find_fn, __find_first_of_fn)
	(__adjacent_find_fn): Cast result of predicate to bool.
	* include/std/concepts (__boolean): Remove.
	(__detail::__boolean_testable_impl, __detail::__boolean_testable): Add
	new helper concepts.
	(__detail::__weakly_eq_cmp_with, totally_ordered, totally_ordered_with)
	(predicate): Use __boolean_testable instead of boolean.
	* libsupc++/compare (__detail::__partially_ordered, _Synth3way):
	Likewise.
2020-02-17 18:22:05 +00:00
Jonathan Wakely
7ab36231a1 libstdc++: P1970R2 Consistency for size() functions: Add ranges::ssize
This defines ranges::ssize as approved in Prague. It's unclear what is
supposed to happen for types for which range_difference_t is not a valid
type. I've assumed they are not meant to be usable with ranges::ssize,
despite being usable with ranges::size.

	* include/bits/range_access.h (_SSize, ssize): Define for C++20.
	* testsuite/std/ranges/access/ssize.cc: New test.
2020-02-17 18:15:41 +00:00
Jonathan Wakely
9866abe31e libstdc++ P1956R1 On the names of low-level bit manipulation functions
Implement this change for C++20 that was just approved in Prague.

	P1956R1 On the names of low-level bit manipulation functions
	* include/bits/hashtable_policy.h: Update comment.
	* include/std/bit (__ispow2, __ceil2, __floor2, __log2p1): Rename.
	(ispow2, ceil2, floor2, log2p1): Likewise.
	(__cpp_lib_int_pow2): Add feature test macro.
	* include/std/charconv (__to_chars_len_2): Adjust use of __log2p1.
	* include/std/memory (assume_aligned): Adjust use of ispow2.
	* include/std/version (__cpp_lib_int_pow2): Add.
	* libsupc++/new_opa.cc: Adjust use of __ispow2.
	* src/c++17/memory_resource.cc: Likewise, and for __ceil2 and __log2p1.
	* testsuite/17_intro/freestanding.cc: Adjust use of ispow2.
	* testsuite/26_numerics/bit/bit.pow.two/ceil2.cc: Rename to ...
	* testsuite/26_numerics/bit/bit.pow.two/bit_ceil.cc: ... here.
	* testsuite/26_numerics/bit/bit.pow.two/ceil2_neg.cc: Rename to ...
	* testsuite/26_numerics/bit/bit.pow.two/bit_ceil_neg.cc: ... here.
	* testsuite/26_numerics/bit/bit.pow.two/floor2.cc: Rename to ...
	* testsuite/26_numerics/bit/bit.pow.two/bit_floor.cc: ... here.
	* testsuite/26_numerics/bit/bit.pow.two/log2p1.cc: Rename to ...
	* testsuite/26_numerics/bit/bit.pow.two/bit_width.cc: ... here.
	* testsuite/26_numerics/bit/bit.pow.two/ispow2.cc: Rename to ...
	* testsuite/26_numerics/bit/bit.pow.two/has_single_bit.cc: ... here.
2020-02-17 17:09:18 +00:00
Jonathan Wakely
cfbc8fbb37 libstdc++: Add comment to <charconv> explaining C++14 status
This header is intentionally valid in C++14 mode, because no conforming
C++14 program will try to include <charconv> and so it's OK to add new
(non-reserved in C++14) names to namespace std. However, other headers
must not include <charconv> transitively prior to C++17, so that we
don't add those non-reserved names without the user requesting it.

This adds a comment to the header explaining that.

	* include/std/charconv: Add comment.
2020-02-17 15:44:03 +00:00
Jonathan Wakely
9cd4eeefcc libstdc++: Reduce header dependencies for C++20 (PR 92546)
In C++20 <memory> depends on <bits/ranges_unitialized.h> which
depends on <bits/random.h> just for a single concept. Including
<bits/random.h> also requires including <cmath>, which is huge due to
the C++17 special functions.

This change moves the concept to the <bits/uniform_int_dist.h> internal
header that exists so that <bits/stl_algobase.h> doesn't need to include
<bits/random.h>.

	PR libstdc++/92546 (partial)
	* include/bits/random.h (uniform_random_bit_generator): Move definition
	to <bits/uniform_int_dist.h>.
	* include/bits/ranges_algo.h: Include <bits/uniform_int_dist.h> instead
	of <bits/random.h>.
	* include/bits/ranges_algobase.h: Do not include <cmath>.
	* include/bits/uniform_int_dist.h (uniform_random_bit_generator):
	Move here.
	* include/std/ranges: Do not include <limits>.
	* testsuite/26_numerics/random/pr60037-neg.cc: Adjust dg-error lineno.
2020-02-17 15:43:43 +00:00
Jonathan Wakely
c03b53da91 libstdc++: Add lightweight replacement for std::numeric_limits (PR 92546)
Many uses of std::numeric_limits in C++17 and C++20 features only really
need the min(), max() and digits constants for integral types. By adding
__detail::__int_limits we can avoid including the whole <limits> header.

The <limits> header isn't especially large, but avoiding it still gives
small savings in compilation time and memory usage for the compiler.

There are also C++11 features that could benefit from this change (e.g.
<bits/hashtable_policy.h> and <bits/uniform_int_dist.h>) but I won't
change those until stage 1.

The implementation of __int_limits assumes two's complement integers,
which is true for all targets supported by GCC.

	PR libstdc++/92546 (partial)
	* include/Makefile.am: Add new header.
	* include/Makefile.in: Regenerate.
	* include/bits/int_limits.h: New header.
	* include/bits/parse_numbers.h (__select_int::_Select_int): Replace
	numeric_limits with __detail::__int_limits.
	* include/std/bit (__rotl, __rotr, __countl_zero, __countl_one)
	(__countr_zero, __countr_one, __popcount, __ceil2, __floor2, __log2p1):
	Likewise.
	* include/std/charconv (__to_chars_8, __from_chars_binary)
	(__from_chars_alpha_to_num, from_chars): Likewise.
	* include/std/memory_resource (polymorphic_allocator::allocate)
	(polymorphic_allocator::allocate_object): Likewise.
	* include/std/string_view (basic_string_view::_S_compare): Likewise.
	* include/std/utility (in_range): Likewise.
	* testsuite/20_util/integer_comparisons/in_range_neg.cc: Adjust for
	extra error about incomplete type __int_limits<bool>.
	* testsuite/26_numerics/bit/bit.count/countl_one.cc: Include <limits>.
	* testsuite/26_numerics/bit/bit.count/countl_zero.cc: Likewise.
	* testsuite/26_numerics/bit/bit.count/countr_one.cc: Likewise.
	* testsuite/26_numerics/bit/bit.count/countr_zero.cc: Likewise.
	* testsuite/26_numerics/bit/bit.count/popcount.cc: Likewise.
	* testsuite/26_numerics/bit/bit.pow.two/ceil2_neg.cc: Likewise.
	* testsuite/26_numerics/bit/bit.pow.two/ceil2.cc: Likewise.
	* testsuite/26_numerics/bit/bit.pow.two/floor2.cc: Likewise.
	* testsuite/26_numerics/bit/bit.pow.two/ispow2.cc: Likewise.
	* testsuite/26_numerics/bit/bit.pow.two/log2p1.cc: Likewise.
	* testsuite/26_numerics/bit/bit.rotate/rotl.cc: Likewise.
	* testsuite/26_numerics/bit/bit.rotate/rotr.cc: Likewise.
2020-02-17 15:11:04 +00:00
Jonathan Wakely
4540ef781b libstdc++: Fix regression in libstdc++-prettyprinters/cxx20.cc
* python/libstdcxx/v6/printers.py (StdCmpCatPrinter.to_string): Update
	value for partial_ordering::unordered.
2020-02-17 13:20:57 +00:00
Jonathan Wakely
d6dfa3dafc libstdc++: Make "implicit expression variants" more explicit (P2102R0)
* include/bits/iterator_concepts.h (indirectly_copyable_storable): Add
	const-qualified expression variations.
	* include/std/concepts (copyable): Likewise.
2020-02-17 13:20:57 +00:00
Jonathan Wakely
98cf2c2659 libstdc++: Implement "Safe Integral Comparisons" (P0586R2)
* include/std/type_traits (__is_standard_integer): New helper trait.
	* include/std/utility (cmp_equal, cmp_not_equal, cmp_less, cmp_greater)
	(cmp_less_equal, cmp_greater_equal, in_range): Define for C++20.
	* include/std/version (__cpp_lib_integer_comparison_functions): Define.
	* testsuite/20_util/integer_comparisons/1.cc: New test.
	* testsuite/20_util/integer_comparisons/2.cc: New test.
	* testsuite/20_util/integer_comparisons/equal.cc: New test.
	* testsuite/20_util/integer_comparisons/equal_neg.cc: New test.
	* testsuite/20_util/integer_comparisons/greater_equal.cc: New test.
	* testsuite/20_util/integer_comparisons/greater_equal_neg.cc: New test.
	* testsuite/20_util/integer_comparisons/greater_neg.cc: New test.
	* testsuite/20_util/integer_comparisons/in_range.cc: New test.
	* testsuite/20_util/integer_comparisons/in_range_neg.cc: New test.
	* testsuite/20_util/integer_comparisons/less.cc: New test.
	* testsuite/20_util/integer_comparisons/less_equal.cc: New test.
	* testsuite/20_util/integer_comparisons/less_equal_neg.cc: New test.
	* testsuite/20_util/integer_comparisons/less_neg.cc: New test.
	* testsuite/20_util/integer_comparisons/not_equal.cc: New test.
	* testsuite/20_util/integer_comparisons/not_equal_neg.cc: New test.
2020-02-17 13:20:57 +00:00
Patrick Palka
93b8cfce27 libstdc++: Move code after an early exit constexpr if to under an else branch
This avoids instantiating dead code when the true branch of the constexpr if is
taken.

libstdc++-v3/ChangeLog:

	* include/bits/ranges_algo.h (__lexicographical_compare_fn::operator()):
	Move code after an early exit constexpr if to under an else branch.
	* include/bits/ranges_algobase.h (__equal_fn::operator()): Likewise.
2020-02-15 21:16:00 -05:00
Patrick Palka
5599262661 libstdc++: Whitespace and formatting adjustments
libstdc++-v3/ChangeLog:

	* include/bits/ranges_algo.h: Adjust whitespace and formatting.
	* include/bits/ranges_algobase.h: Likewise.
	* include/bits/ranges_uninitialized.h: Likewise.
2020-02-15 10:57:02 -05:00
Patrick Palka
b40c57bdd2 libstdc++: Convert the ranges algorithm entities into function objects
This is the standard way to inhibit ADL for these entities, which is required as
per [algorithms.requirements] p2 and [specialized.algorithms] p4.  The
conversion was done mostly mechanically with a custom Vim macro.

libstdc++-v3/ChangeLog:

	* include/bits/ranges_algo.h: (adjacent_find, all_of, any_of,
	binary_search, copy_if, count, count_if, equal_range, find, find_end,
	find_first_of, find_if, find_if_not, for_each, generate, generate_n,
	includes, inplace_merge, is_heap, is_heap_until, is_partitioned,
	is_permutation, is_sorted, is_sorted_until, lexicographical_compare,
	lower_bound, make_heap, max, max_element, merge, min, min_element,
	minmax, minmax_element, mismatch, next_permutation, none_of,
	nth_element, partial_sort, partial_sort_copy, partition, partition_copy,
	partition_point, pop_heap, prev_permutation, push_heap, remove,
	remove_copy, remove_copy_if, remove_if, replace, replace_copy,
	replace_copy_if, replace_if, reverse, reverse_copy, rotate, rotate_copy,
	search, search_n, set_difference, set_intersection,
	set_symmetric_difference, set_union, shuffle, sort, sort_heap,
	stable_partition, stable_sort, swap_ranges, transform, unique,
	unique_copy, upper_bound): Convert into function objects.
	* include/bits/ranges_algobase.h: (equal, copy, move, copy_n, fill_n,
	fill, move_backward, copy_backward): Likewise.
	* include/bits/ranges_uninitialized.h (uninitialized_default_construct,
	uninitialized_default_construct_n, uninitialized_value_construct,
	uninitialized_value_construct_n, uninitialized_copy,
	uninitialized_copy_n, uninitialized_move, uninitialized_move_n,
	uninitialized_fill, uninitialized_fill_n, construct_at, destroy_at,
	destroy, destroy_n): Likewise.
2020-02-15 10:56:10 -05:00
Patrick Palka
90b7eb6539 libstdc++: Fold some ranges algo subroutines into their only caller
These subroutines have only a single call site, so it might be best and simplest
to eliminate them before we convert the algos into function objects.

libstdc++-v3/ChangeLog:

	* include/bits/ranges_algo.h (ranges::__find_end): Fold into ...
	(ranges::find_end): ... here.
	(ranges::__lexicographical_compare): Fold into ...
	(ranges::lexicographical_compare): ... here.
	* include/bits/ranges_algobase.h (ranges::__equal): Fold into ...
	(ranges::equal): ... here.
2020-02-15 10:55:25 -05:00
Jonathan Wakely
55b00d14f4 libstdc++: Update __cpp_lib_erase_if macro (P1115R3)
Now that this feature has been approved for C++20 we can define the
macro to the official value.

	* include/bits/erase_if.h (__cpp_lib_erase_if): Define to 202002L.
	* include/std/deque: Likewise.
	* include/std/forward_list: Likewise.
	* include/std/list: Likewise.
	* include/std/string: Likewise.
	* include/std/vector: Likewise.
	* include/std/version: Likewise.
	* testsuite/23_containers/deque/erasure.cc: Test for new value.
	* testsuite/23_containers/forward_list/erasure.cc: Likewise.
	* testsuite/23_containers/list/erasure.cc: Likewise.
	* testsuite/23_containers/map/erasure.cc: Likewise.
	* testsuite/23_containers/set/erasure.cc: Likewise.
	* testsuite/23_containers/unordered_map/erasure.cc: Likewise.
	* testsuite/23_containers/unordered_set/erasure.cc: Likewise.
	* testsuite/23_containers/vector/erasure.cc: Likewise.
2020-02-15 10:25:23 +00:00
Jonathan Wakely
5b1d588509 libstdc++: Implement LWG 3150 for std::uniform_random_bit_generator
* include/bits/random.h (uniform_random_bit_generator): Require min()
	and max() to be constant expressions and min() to be less than max().
	* testsuite/26_numerics/random/concept.cc: Check additional cases.
	* testsuite/26_numerics/random/pr60037-neg.cc: Adjust dg-error lineno.
2020-02-15 10:24:57 +00:00
Patrick Palka
613c932f5e libstdc++: Implement ranges [specialized.algorithms]
This implements all the ranges members defined in [specialized.algorithms]:

  ranges::uninitialized_default_construct
  ranges::uninitialized_value_construct
  ranges::uninitialized_copy
  ranges::uninitialized_copy_n
  ranges::uninitialized_move
  ranges::uninitialized_move_n
  ranges::uninitialized_fill
  ranges::uninitialized_fill_n
  ranges::construct_at
  ranges::destroy_at
  ranges::destroy

It also implements (hopefully correctly) the "obvious" optimizations for these
algos, namely that if the output range has a trivial value type and if the
appropriate operation won't throw then we can dispatch to the standard ranges
version of the algorithm which will then potentially enable further
optimizations.

libstdc++-v3/ChangeLog:

	* include/Makefile.am: Add <bits/ranges_uninitialized.h>.
	* include/Makefile.in: Regenerate.
	* include/bits/ranges_uninitialized.h: New header.
	* include/std/memory: Include it.
	* testsuite/20_util/specialized_algorithms/destroy/constrained.cc: New
	test.
	* .../uninitialized_copy/constrained.cc: New test.
	* .../uninitialized_default_construct/constrained.cc: New test.
	* .../uninitialized_fill/constrained.cc: New test.
	* .../uninitialized_move/constrained.cc: New test.
	* .../uninitialized_value_construct/constrained.cc: New test.
2020-02-13 15:22:28 -05:00
Patrick Palka
90fc7b3ce0 libstdc++: Move some ranges algos to a new header <bits/ranges_algobase.h>
This roughly mirrors the existing split between <bits/stl_algo.h> and
<bits/stl_algobase.h>.  The ranges [specialized.algorithms] will use this new
header to avoid including all of of <bits/ranges_algo.h>.

libstdc++-v3/ChangeLog:

	* include/Makefile.am: Add bits/ranges_algobase.h
	* include/Makefile.in: Regenerate.
	* bits/ranges_algo.h: Include <bits/ranges_algobase.h> and refactor
	existing #includes.
	(__detail::__is_normal_iterator, __detail::is_reverse_iterator,
	__detail::__is_move_iterator, copy_result, move_result,
	__equal, equal, copy_result, move_result, move_backward_result,
	copy_backward_result, __copy_or_move_backward, __copy_or_move, copy,
	move, copy_backward, move_backward, copy_n_result, copy_n, fill_n,
	fill): Split out into ...
	* bits/range_algobase.h: ... this new header.
2020-02-13 15:20:49 -05:00
Patrick Palka
99bbab9f77 libstdc++: Fix LWG issues 3389 and 3390
libstdc++-v3/ChangeLog:

	LWG 3389 and LWG 3390
	* include/bits/stl_iterator.h (move_move_iterator): Use std::move when
	constructing the move_iterator with __i.
	(counted_iterator::counted_iterator): Use std::move when initializing
	M_current with __i.
	* testsuite/24_iterators/counted_iterator/lwg3389.cc: New test.
	* testsuite/24_iterators/move_iterator/lwg3390.cc: New test.
2020-02-12 16:30:19 -05:00
Sandra Loosemore
02ce382cd3 Use a non-empty test program to test ability to link.
On bare-metal targets, I/O support is typically provided by a BSP and
requires a linker script and/or hosting library to be specified on the
linker command line.  Linking an empty program with the default linker
script may succeed, however, which confuses libstdc++ configuration
when programs that probe for the presence of various I/O features fail
with link errors.

2020-02-12  Sandra Loosemore  <sandra@codesourcery.com>

	PR libstdc++/79193
	PR libstdc++/88999

	config/
	* no-executables.m4: Use a non-empty program to test for linker
	support.

	libgcc/
	* configure: Regenerated.

	libgfortran/
	* configure: Regenerated.

	libiberty/
	* configure: Regenerated.

	libitm/
	* configure: Regenerated.

	libobjc/
	* configure: Regenerated.

	libquadmath/
	* configure: Regenerated.

	libssp/
	* configure: Regenerated.

	libstdc++v-3/
	* configure: Regenerated.
2020-02-12 13:22:07 -08:00
François Dumont
b32a3f3243 libstdc++: Add missing std:: qualification of a forward call
* include/bits/hashtable.h
	(_Hashtable<>(_Hashtable&&, std::allocator_type&)): Add
	missing std namespace qualification to forward call.
2020-02-12 22:09:41 +01:00
Jonathan Wakely
38660e87f0 libstdc++: Fix names of types in comment
* testsuite/20_util/function_objects/range.cmp/equal_to.cc: Fix
	comment.
	* testsuite/20_util/function_objects/range.cmp/less.ccL Likewise.
2020-02-09 14:00:23 +00:00
Jonathan Wakely
97a7c22955 libstdc++: Fix non-ASCII characters in comment
* include/std/ranges: Fix non-ASCII characters in comment.
2020-02-09 13:54:32 +00:00
Jonathan Wakely
dcda050e6c libstdc++: Fix BUILTIN-PTR-CMP helpers
The helpers that implement BUILTIN-PTR-CMP do not currently check if the
arguments are actually comparable, so the concept is true when it
shouldn't be.

Since we're trying to test for an unambiguous conversion to pointers, we
can also require that it returns bool, because the built-in comparisons
for pointers do return bool.

	* include/bits/range_cmp.h (__detail::__eq_builtin_ptr_cmp): Require
	equality comparison to be valid and return bool.
	(__detail::__less_builtin_ptr_cmp): Likewise for less-than comparison.
	* testsuite/20_util/function_objects/range.cmp/equal_to.cc: Check
	type with ambiguous conversion to fundamental types.
	* testsuite/20_util/function_objects/range.cmp/less.cc: Likewise.
2020-02-09 13:37:43 +00:00