| 1 |
//===----------------------------------------------------------------------===// |
| 2 |
// |
| 3 |
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 |
// See https://llvm.org/LICENSE.txt for license information. |
| 5 |
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 |
// |
| 7 |
//===----------------------------------------------------------------------===// |
| 8 |
|
| 9 |
// UNSUPPORTED: c++03, c++11, c++14, c++17 |
| 10 |
|
| 11 |
// <iterator> |
| 12 |
// |
| 13 |
// reverse_iterator |
| 14 |
// |
| 15 |
// pointer operator->() const; |
| 16 |
|
| 17 |
#include <iterator> |
| 18 |
|
| 19 |
#include <type_traits> |
| 20 |
#include "test_iterators.h" |
| 21 |
|
| 22 |
template <class T> |
| 23 |
concept HasArrow = requires(T t) { t.operator->(); }; |
| 24 |
|
| 25 |
struct simple_bidirectional_iterator { |
| 26 |
using iterator_category = std::bidirectional_iterator_tag; |
| 27 |
using value_type = int; |
| 28 |
using difference_type = int; |
| 29 |
using pointer = int*; |
| 30 |
using reference = int&; |
| 31 |
|
| 32 |
reference operator*() const; |
| 33 |
pointer operator->() const; |
| 34 |
|
| 35 |
simple_bidirectional_iterator& operator++(); |
| 36 |
simple_bidirectional_iterator& operator--(); |
| 37 |
simple_bidirectional_iterator operator++(int); |
| 38 |
simple_bidirectional_iterator operator--(int); |
| 39 |
|
| 40 |
friend bool operator==(const simple_bidirectional_iterator&, const simple_bidirectional_iterator&); |
| 41 |
}; |
| 42 |
static_assert( std::bidirectional_iterator<simple_bidirectional_iterator>); |
| 43 |
static_assert(!std::random_access_iterator<simple_bidirectional_iterator>); |
| 44 |
|
| 45 |
using PtrRI = std::reverse_iterator<int*>; |
| 46 |
static_assert( HasArrow<PtrRI>); |
| 47 |
|
| 48 |
using PtrLikeRI = std::reverse_iterator<simple_bidirectional_iterator>; |
| 49 |
static_assert( HasArrow<PtrLikeRI>); |
| 50 |
|
| 51 |
// `bidirectional_iterator` from `test_iterators.h` doesn't define `operator->`. |
| 52 |
using NonPtrRI = std::reverse_iterator<bidirectional_iterator<int*>>; |
| 53 |
static_assert(!HasArrow<NonPtrRI>); |