1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11, c++14, c++17
15 // pointer operator->() const;
19 #include <type_traits>
20 #include "test_iterators.h"
23 concept HasArrow
= requires(T t
) { t
.operator->(); };
25 struct simple_bidirectional_iterator
{
26 using iterator_category
= std::bidirectional_iterator_tag
;
27 using value_type
= int;
28 using difference_type
= int;
30 using reference
= int&;
32 reference
operator*() const;
33 pointer
operator->() const;
35 simple_bidirectional_iterator
& operator++();
36 simple_bidirectional_iterator
& operator--();
37 simple_bidirectional_iterator
operator++(int);
38 simple_bidirectional_iterator
operator--(int);
40 friend bool operator==(const simple_bidirectional_iterator
&, const simple_bidirectional_iterator
&);
42 static_assert( std::bidirectional_iterator
<simple_bidirectional_iterator
>);
43 static_assert(!std::random_access_iterator
<simple_bidirectional_iterator
>);
45 using PtrRI
= std::reverse_iterator
<int*>;
46 static_assert( HasArrow
<PtrRI
>);
48 using PtrLikeRI
= std::reverse_iterator
<simple_bidirectional_iterator
>;
49 static_assert( HasArrow
<PtrLikeRI
>);
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
>);