[Flang] Add semantics checks for CrayPointer usage in DSA list (#123171)
[llvm-project.git] / libcxx / test / std / iterators / predef.iterators / reverse.iterators / reverse.iter.elem / arrow.sfinae.compile.pass.cpp
blobb723176a19c45fa518dfe9ef5a34579a3d8074d1
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 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11, c++14, c++17
11 // <iterator>
13 // reverse_iterator
15 // pointer operator->() const;
17 #include <iterator>
19 #include <type_traits>
20 #include "test_iterators.h"
22 template <class T>
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;
29 using pointer = 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>);