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 // UNSUPPORTED: libcpp-no-concepts
11 
12 // template<class I>
13 //   concept permutable = see below; // Since C++20
14 
15 #include <iterator>
16 
17 #include "test_iterators.h"
18 
19 using AllConstraintsSatisfied = forward_iterator<int*>;
20 static_assert( std::forward_iterator<AllConstraintsSatisfied>);
21 static_assert( std::indirectly_movable_storable<AllConstraintsSatisfied, AllConstraintsSatisfied>);
22 static_assert( std::indirectly_swappable<AllConstraintsSatisfied>);
23 static_assert( std::permutable<AllConstraintsSatisfied>);
24 
25 using NotAForwardIterator = cpp20_input_iterator<int*>;
26 static_assert(!std::forward_iterator<NotAForwardIterator>);
27 static_assert( std::indirectly_movable_storable<NotAForwardIterator, NotAForwardIterator>);
28 static_assert( std::indirectly_swappable<NotAForwardIterator>);
29 static_assert(!std::permutable<NotAForwardIterator>);
30 
31 struct NonCopyable {
32   NonCopyable(const NonCopyable&) = delete;
33   NonCopyable& operator=(const NonCopyable&) = delete;
34   friend void swap(NonCopyable&, NonCopyable&);
35 };
36 using NotIMS = forward_iterator<NonCopyable*>;
37 
38 static_assert( std::forward_iterator<NotIMS>);
39 static_assert(!std::indirectly_movable_storable<NotIMS, NotIMS>);
40 static_assert( std::indirectly_swappable<NotIMS>);
41 static_assert(!std::permutable<NotIMS>);
42 
43 // Note: it is impossible for an iterator to satisfy `indirectly_movable_storable` but not `indirectly_swappable`:
44 // `indirectly_swappable` requires both iterators to be `indirectly_readable` and for `ranges::iter_swap` to be
45 // well-formed for both iterators. `indirectly_movable_storable` also requires the iterator to be `indirectly_readable`.
46 // `ranges::iter_swap` is always defined for `indirectly_movable_storable` iterators.
47