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