Skip to content

Commit

Permalink
[libc++][ranges][NFC] Test new requirements for basic_string_view a…
Browse files Browse the repository at this point in the history
…nd `span` iterators.

Note that most changes to `strings` and `views.span` from the One Ranges
Proposal are no longer applicable:
- free `begin` and `end` functions taking `basic_string_view` and `span`
  were removed by [P1870](http://wg21.link/p1870);
- `span::const_iterator` was removed by [LWG3320](https://cplusplus.github.io/LWG/lwg-defects.html#3320).

Reviewed By: #libc, Quuxplusone, ldionne

Differential Revision: https://reviews.llvm.org/D118687
  • Loading branch information
var-const committed Feb 2, 2022
1 parent f681d7d commit 298331f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions libcxx/docs/Status/RangesPaper.csv
Expand Up @@ -32,8 +32,8 @@ Section,Description,Dependencies,Assignee,Complete
| `ranges::destroy <https://llvm.org/D116078>`_
| `ranges::destroy_at <https://llvm.org/D116078>`_
| `ranges::destroy_n <https://llvm.org/D116078>`_",[special.mem.concepts],Konstantin Varlamov,✅
`[strings] <https://wg21.link/strings>`_,Adds begin/end and updates const_iterator.,[iterator.concepts],Unassigned,Not started
`[views.span] <https://wg21.link/views.span>`_,Same as [strings],[iterator.concepts],Unassigned,Not started
`[strings] <https://wg21.link/strings>`_,`Adds begin/end and updates const_iterator. <https://llvm.org/D118687>`_,[iterator.concepts],Konstantin Varlamov,✅
`[views.span] <https://wg21.link/views.span>`_,`Same as [strings] <https://llvm.org/D118687>`_,[iterator.concepts],Konstantin Varlamov,✅
`[iterator.cust.move] <https://wg21.link/iterator.cust.move>`_,`ranges::iter_move <https://llvm.org/D99873>`_,,Zoe Carver,✅
`[iterator.cust.swap] <https://wg21.link/iterator.cust.swap>`_,`ranges::iter_swap <https://llvm.org/D102809>`_,iter_value_t,Zoe Carver,✅
`[iterator.concepts] <https://wg21.link/iterator.concepts>`_,"| `indirectly_readable <https://llvm.org/D100073>`_
Expand Down
Expand Up @@ -14,12 +14,14 @@
#include <span>

#include <iterator>
#include "test_macros.h"

using iterator = std::span<int>::iterator;
using reverse_iterator = std::span<int>::reverse_iterator;
using value_type = int;

static_assert(std::contiguous_iterator<iterator>);
LIBCPP_STATIC_ASSERT(std::__is_cpp17_random_access_iterator<iterator>::value);
static_assert(std::indirectly_writable<iterator, value_type>);
static_assert(std::sentinel_for<iterator, iterator>);
static_assert(!std::sentinel_for<iterator, reverse_iterator>);
Expand Down
Expand Up @@ -15,12 +15,15 @@

#include <iterator>

#include "test_macros.h"

using iterator = std::string_view::iterator;
using const_iterator = std::string_view::const_iterator;
using reverse_iterator = std::string_view::reverse_iterator;
using const_reverse_iterator = std::string_view::const_reverse_iterator;

static_assert(std::contiguous_iterator<iterator>);
LIBCPP_STATIC_ASSERT(std::__is_cpp17_random_access_iterator<iterator>::value);
static_assert(!std::indirectly_writable<iterator, char>);
static_assert(std::sentinel_for<iterator, iterator>);
static_assert(std::sentinel_for<iterator, const_iterator>);
Expand All @@ -35,6 +38,7 @@ static_assert(std::indirectly_movable_storable<iterator, char*>);
static_assert(!std::indirectly_swappable<iterator, iterator>);

static_assert(std::contiguous_iterator<const_iterator>);
LIBCPP_STATIC_ASSERT(std::__is_cpp17_random_access_iterator<const_iterator>::value);
static_assert(!std::indirectly_writable<const_iterator, char>);
static_assert(std::sentinel_for<const_iterator, iterator>);
static_assert(std::sentinel_for<const_iterator, const_iterator>);
Expand Down

0 comments on commit 298331f

Please sign in to comment.