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