46 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// UNSUPPORTED: c++03, c++11, c++14, c++1710 11// template<class I>12// concept permutable = see below; // Since C++2013 14#include <iterator>15 16#include "test_iterators.h"17 18using AllConstraintsSatisfied = forward_iterator<int*>;19static_assert( std::forward_iterator<AllConstraintsSatisfied>);20static_assert( std::indirectly_movable_storable<AllConstraintsSatisfied, AllConstraintsSatisfied>);21static_assert( std::indirectly_swappable<AllConstraintsSatisfied>);22static_assert( std::permutable<AllConstraintsSatisfied>);23 24using NotAForwardIterator = cpp20_input_iterator<int*>;25static_assert(!std::forward_iterator<NotAForwardIterator>);26static_assert( std::indirectly_movable_storable<NotAForwardIterator, NotAForwardIterator>);27static_assert( std::indirectly_swappable<NotAForwardIterator>);28static_assert(!std::permutable<NotAForwardIterator>);29 30struct NonCopyable {31 NonCopyable(const NonCopyable&) = delete;32 NonCopyable& operator=(const NonCopyable&) = delete;33 friend void swap(NonCopyable&, NonCopyable&);34};35using NotIMS = forward_iterator<NonCopyable*>;36 37static_assert( std::forward_iterator<NotIMS>);38static_assert(!std::indirectly_movable_storable<NotIMS, NotIMS>);39static_assert( std::indirectly_swappable<NotIMS>);40static_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 be44// 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