Commit Graph

175 Commits

Author SHA1 Message Date
zoecarver 4ac87e3378 [libcxx][ranges] Add `unreachable_sentinel`.
Differential Revision: https://reviews.llvm.org/D107920
2021-08-12 10:11:27 -07:00
zoecarver 8a48e6dda9 [libcxx][ranges] Add `counted_iterator`.
Differential Revision: https://reviews.llvm.org/D106205
2021-07-27 15:50:11 -07:00
Louis Dionne 7b28c5d376 [libc++] Implement the output_iterator and output_range concepts
Differential Revision: https://reviews.llvm.org/D106704
2021-07-26 15:05:17 -04:00
zoecarver 1a29403d2f [libcxx][ranges] Add common_iterator.
Differential Revision: https://reviews.llvm.org/D103335
2021-07-20 08:12:44 -07:00
Christopher Di Bella 8517a26d44 [libcxx][modularisation] splices `<iterator>` into individual headers
Differential Revision: https://reviews.llvm.org/D105076
2021-07-06 17:59:21 +00:00
zoecarver edc1f0c12c [libcxx][ranges] Implement indirectly_swappable.
Differential Revision: https://reviews.llvm.org/D105304
2021-07-01 15:08:23 -07:00
Louis Dionne f32f3db9fc [libc++] Split the various iterator types out of <iterator>
Differential Revision: https://reviews.llvm.org/D104669
2021-06-28 12:25:40 -04:00
Christopher Di Bella 6adbc83ee9 [libcxx][modularisation] moves <utility> content out of <type_traits>
Moves:

* `std::move`, `std::forward`, `std::declval`, and `std::swap` into
  `__utility/${FUNCTION_NAME}`.
* `std::swap_ranges` and `std::iter_swap` into
  `__algorithm/${FUNCTION_NAME}`

Differential Revision: https://reviews.llvm.org/D103734
2021-06-24 17:57:29 +00:00
zoecarver 40d6d2c49d [libcxx][ranges] Add `ranges::iter_swap`.
Differential Revision: https://reviews.llvm.org/D102809
2021-06-22 09:52:40 -07:00
zoecarver 075f2370c7 [libcxx][ranges] Add `indirectly_movable` and `indirectly_movable_storable`.
Differential Revision: https://reviews.llvm.org/D102639
2021-06-21 12:39:25 -07:00
Louis Dionne c54d3050f7 [libc++] NFC: Move indirect_concepts.h to __iterator/concepts.h
There's no fundamental reason to separate those from the other iterator
concepts.

Differential Revision: https://reviews.llvm.org/D104048
2021-06-11 12:57:04 -04:00
Christopher Di Bella 462f8f0611 [libcxx][ranges] removes default_initializable from weakly_incrementable and view
also:

* removes default constructors from predefined iterators
* makes span and string_view views

Partially implements P2325.
Partially resolves LWG3326.

Differential Revision: https://reviews.llvm.org/D102468
2021-06-10 22:45:36 +00:00
Louis Dionne e4d3a993c2 [libc++] Implement LWG3435 (constraints on reverse_iterator and move_iterator) 2021-06-03 15:49:41 -04:00
zoecarver 065cf3f9d7 [libcxx][ranges] Add `default_sentinel` and `default_sentinel_t`.
Refs https://eel.is/c++draft/default.sentinel and https://eel.is/c++draft/iterator.synopsis

Differential Revision: https://reviews.llvm.org/D103487
2021-06-01 14:03:54 -07:00
Christopher Di Bella bf92bdad77 [libcxx][nfc] moves std `advance`, `next`, and `prev` into their headers
Differential Revision: https://reviews.llvm.org/D103329
2021-05-31 17:14:52 +00:00
Louis Dionne 41bdf64d3e [libc++] Update all the pre-defined iterator types for C++20
Make sure we provide the correct It::difference_type member and update
the tests and synopses to be accurate.

Supersedes D102657 and D103101 (thanks to the original authors).

Differential Revision: https://reviews.llvm.org/D103273
2021-05-31 11:59:40 -04:00
Louis Dionne 58b29a4efc [libc++] Add all indirect callable concepts and projected
Differential Revision: https://reviews.llvm.org/D101277
2021-05-28 10:10:44 -04:00
Louis Dionne 1055cb91b4 [libc++] Deprecate std::iterator and remove it as a base class
C++17 deprecated std::iterator and removed it as a base class for all
iterator adaptors. We implement that change, but we still provide a way
to inherit from std::iterator in the few cases where doing otherwise
would be an ABI break.

Supersedes D101729 and the std::iterator base parts of D103101 and D102657.

Differential Revision: https://reviews.llvm.org/D103171
2021-05-27 11:34:04 -04:00
Christopher Di Bella 0dc7fd1bc1 [libcxx][iterator] adds `std::ranges::prev`
Implements part of P0896 'The One Ranges Proposal'.
Implements [range.iter.op.prev].

Depends on D102563.

Differential Revision: https://reviews.llvm.org/D102564
2021-05-27 04:41:27 +00:00
Christopher Di Bella 857fa7b7b1 [libcxx][iterator] adds `std::ranges::next`
Implements part of P0896 'The One Ranges Proposal'.
Implements [range.iter.op.next].

Depends on D101922.

Differential Revision: https://reviews.llvm.org/D102563
2021-05-27 04:41:26 +00:00
Christopher Di Bella 36d0fdf9ac [libcxx][iterator] adds `std::ranges::advance`
Implements part of P0896 'The One Ranges Proposal'.
Implements [range.iter.op.advance].

Differential Revision: https://reviews.llvm.org/D101922
2021-05-26 04:27:30 +00:00
Arthur O'Dwyer fc9248877d [libc++] Assume that __wrap_iter always wraps a fancy pointer.
Not only do we conscientiously avoid using `__wrap_iter` for non-contiguous
iterators (in vector, string, span...) but also we make the assumption
(in regex) that `__wrap_iter<_Iter>` is contiguous for all `_Iter`.

So `__wrap_iter<reverse_iterator<int*>>` should be considered IFNDR,
and every `__wrap_iter` should correctly advertise contiguity in C++20.

Drive-by simplify some type traits.

Reviewed as part of https://reviews.llvm.org/D102781
2021-05-24 17:30:21 -04:00
Kristina Bessonova 96100f1508 [libcxx] NFC. Correct wordings of _LIBCPP_ASSERT debug messages
Differential Revision: https://reviews.llvm.org/D102195
2021-05-12 13:49:57 +02:00
Louis Dionne fe0e86e602 [libc++] Rewrite std::to_address to avoid relying on element_type
This is a rough reapplication of the change that fixed std::to_address
to avoid relying on element_type (da456167). It is somewhat different
because the fix to avoid breaking Clang (which caused it to be reverted
in 347f69c55) was a bit more involved.

Differential Revision: https://reviews.llvm.org/D101638
2021-05-06 10:14:11 -04:00
Arthur O'Dwyer 9571b8f238 [libc++] [LIBCXX-DEBUG-FIXME] std::advance shouldn't use ADL `>=` on the _Distance type.
Convert to a primitive type first; then use primitive `>=` on that value.

Differential Revision: https://reviews.llvm.org/D101678
2021-05-05 16:21:09 -04:00
zoecarver 6ffc41b014 [libcxx][ranges] Add `random_access_{iterator,range}`.
Differential Revision: https://reviews.llvm.org/D101316
2021-05-04 21:42:55 -07:00
Louis Dionne 347f69c55f [libc++] Revert the std::to_address change to avoid relying on element_type.
This reverts commit da456167, which broke the Clang build. I'm able to
reproduce it but I want to give myself a bit more time to investigate.

Differential Revision: https://reviews.llvm.org/D101638
2021-05-04 18:50:05 -04:00
Arthur O'Dwyer da456167f5 [libc++] Make sure std::to_address doesn't depend on P::element_type.
Differential Revision: https://reviews.llvm.org/D101638
2021-05-04 16:59:25 -04:00
Christopher Di Bella 9c5d86aac5 [libcxx][iterator][ranges] adds `bidirectional_iterator` and `bidirectional_range`
Implements parts of:
    * P0896R4 The One Ranges Proposal`

Depends on D100275.

Differential Revision: https://reviews.llvm.org/D100278
2021-05-03 21:21:33 +00:00
Christopher Di Bella fa3e26266c [libcxx][iterator][ranges] adds `forward_iterator` and `forward_range`
Implements parts of:
    * P0896R4 The One Ranges Proposal`

Depends on D100271.

Differential Revision: https://reviews.llvm.org/D100275
2021-05-03 20:46:18 +00:00
Christopher Di Bella c05d1eed35 [libcxx][iterator][ranges] adds `input_iterator` and `input_range`
Implements parts of:
    * P0896R4 The One Ranges Proposal`

Depends on D100269.

Differential Revision: https://reviews.llvm.org/D100271
2021-04-30 22:49:06 +00:00
Arthur O'Dwyer 5f51fb3421 [libc++] Minor cleanups in <iterator>. NFCI. 2021-04-30 08:52:58 -04:00
zoecarver bdd6835790 [libc++][ranges] iterator.concept.sizedsentinel: sized_sentinel_for and disable_sized_sentinel_for.
Based on D100160.

Reviewed By: cjdb, ldionne, Quuxplusone, #libc, miscco

Differential Revision: https://reviews.llvm.org/D100587
2021-04-26 15:06:19 -07:00
Arthur O'Dwyer e87479b00f [libc++] Remove the special logic for "noexcept iterators" in basic_string.
This reverts a large chunk of http://reviews.llvm.org/D15862 ,
and also fixes bugs in `insert`, `append`, and `assign`, which are now regression-tested.
(Thanks to Tim Song for pointing out the bug in `append`!)

Before this patch, we did a special dance in `append`, `assign`, and `insert`
(but not `replace`). All of these require the strong exception guarantee,
even when the user-provided InputIterator might have throwing operations.

The naive way to accomplish this is to construct a temporary string and
then append/assign/insert from the temporary; i.e., finish all the potentially
throwing and self-inspecting InputIterator operations *before* starting to
modify self. But this is slow, so we'd like to skip it when possible.

The old code (D15682) attempted to check that specific iterator operations
were nothrow: it assumed that if the iterator operations didn't throw, then
it was safe to iterate the input range multiple times and therefore it was
safe to use the fast-path non-naive version. This was wrong for two reasons:
(1) the old code checked the wrong operations (e.g. checked noexceptness of `==`,
but the code that ran used `!=`), and (2) the conversion of value_type to char
could still throw, or inspect the contents of self.

The new code is much simpler, although still much more complicated than it
really could be. We'll likely revisit this codepath at some point, but for now
this patch suffices to get it passing all the new regression tests.

The added tests all fail before this patch, and succeed afterward.
See https://quuxplusone.github.io/blog/2021/04/17/pathological-string-appends/

Differential Revision: https://reviews.llvm.org/D98573
2021-04-26 16:22:43 -04:00
Mark de Wever 18b03b0085 [libc++][NFC] Remove non-ASCII from comment.
Seems our check-generated-output doesn't work as intended. Will
investigate it further.
2021-04-26 17:53:20 +02:00
Christopher Di Bella 38225d6921 [libcxx][iterator] adds `std::input_or_output_iterator` and `std::sentinel_for`
Implements parts of:
    * P0896R4 The One Ranges Proposal`

Depends on D100080

Differential Revision: https://reviews.llvm.org/D100160
2021-04-24 15:49:21 +00:00
Christopher Di Bella 2205286095 [libcxx][iterator] adds `std::weakly_incrementable` and `std::incrementable`
Implements parts of:
    * P0896R4 The One Ranges Proposal`

Depends on D100073.

Reviewed By: ldionne, zoecarver, #libc

Differential Revision: https://reviews.llvm.org/D100080
2021-04-23 22:25:37 -07:00
Louis Dionne 57ebf3d008 [libc++] Re-apply `std::indirectly_readable` and `std::indirectly_writable`
That was originally committed in 04733181b5 and then reverted in
a9f11cc0d9 because it broke several people.

The problem was a missing include of __iterator/concepts.h, which has now
been fixed.

Differential Revision: https://reviews.llvm.org/D100073
2021-04-22 11:24:04 -04:00
David Zarzycki a9f11cc0d9 Revert "[libcxx][iterator] adds `std::indirectly_readable` and `std::indirectly_writable`"
This reverts commit 04733181b5 which was
failing for multiple people.
2021-04-22 09:49:54 -04:00
Christopher Di Bella 04733181b5 [libcxx][iterator] adds `std::indirectly_readable` and `std::indirectly_writable`
Implements parts of:
    * P0896R4 The One Ranges Proposal`

Depends on D99873.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D100073
2021-04-21 17:14:28 +00:00
Louis Dionne 97e383aa06 [libc++] Add std::ranges::iter_move and std::iter_rvalue_reference_t
Original patch by @cjdb, modified by @ldionne.

Differential Revision: https://reviews.llvm.org/D99873
2021-04-21 11:32:00 -04:00
Christopher Di Bella 9816d43cff [libcxx] adds `iter_difference_t` and `iter_value_t`
Implements parts of:
    * P0896R4 The One Ranges Proposal

Depends on D99855.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D99863
2021-04-20 19:02:07 +00:00
Louis Dionne 4cd6ca102a [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
zoecarver 120fa8293e [libc++][nfc] Move iterator_traits and related into __iterator/iterator_traits.h.
Based on D100682 and D99855.

(Note: I originally was going to just make this part of D99855, but I decided not to because this patch moves lots of unrelated code around, and I didn't want to make D99855 harder to review because of unrelated code-changes/moves.)

Differential Revision: https://reviews.llvm.org/D100686
2021-04-20 08:31:34 -07:00
zoecarver 9f01ac3b32 [libcxx] makes `iterator_traits` C++20-aware
* adds `iterator_traits` specialisation that supports all expected
  member aliases except for `pointer`
* adds `iterator_traits` specialisations for iterators that meet the
  legacy iterator requirements but might lack multiple member aliases
* makes pointer `iterator_traits` specialisation require objects

Depends on D99854.

Differential Revision: https://reviews.llvm.org/D99855
2021-04-20 11:30:08 -04:00
zoecarver e0adf7e06a [libc++][NFC] Move incrementable_traits and indirectly_readable_traits into separate headers.
Differential Revision: https://reviews.llvm.org/D100682
2021-04-19 14:31:30 -04:00
Arthur O'Dwyer 863d5c4e4d [libc++] Remove hard tabs, U+00AD, and U+200B from all libc++ headers. NFCI. 2021-04-17 17:03:20 -04:00
Christopher Di Bella 0148b65372 [libcxx] adds `cpp17-.*iterator` concepts for iterator_traits
The `iterator_traits` patch became too large for a concise review, so
the "bloat" —as it were— was moved into this patch. Also tests most
C++[98,17] iterator types to confirm backwards compatibility is
successful (regex iterators are intentionally not present, but directory
iterators are due to a peculiar error encountered while patching
`iterator_traits`).

Depends on D99461.

Differential Revision: https://reviews.llvm.org/D99854
2021-04-16 03:14:42 +00:00
Christopher Di Bella f280505aa0 [libcxx] adds `std::indirectly_readable_traits` to <iterator>
Implements parts of:
    * P0896R4 The One Ranges Proposal
    * LWG3446 `indirectly_readable_traits` ambiguity for types with both `value_type` and `element_type`

Depends on D99141.

Differential Revision: https://reviews.llvm.org/D99461
2021-04-15 23:59:02 +00:00
Louis Dionne f992cfba71 [libc++] Split up __memory/base.h into meaningful headers 2021-04-14 13:59:03 -04:00