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 // UNSUPPORTED: gcc-10 12 13 // template<class In, class Out> 14 // concept indirectly_movable; 15 16 #include <iterator> 17 18 #include "test_macros.h" 19 20 struct IndirectlyMovableWithInt { 21 int& operator*() const; 22 }; 23 24 struct Empty {}; 25 26 struct MoveOnly { 27 MoveOnly(MoveOnly&&) = default; 28 MoveOnly(MoveOnly const&) = delete; 29 MoveOnly& operator=(MoveOnly&&) = default; 30 MoveOnly& operator=(MoveOnly const&) = delete; 31 MoveOnly() = default; 32 }; 33 34 template<class T> 35 struct PointerTo { 36 using value_type = T; 37 T& operator*() const; 38 }; 39 40 static_assert( std::indirectly_movable<int*, int*>); 41 static_assert( std::indirectly_movable<const int*, int *>); 42 static_assert(!std::indirectly_movable<int*, const int *>); 43 static_assert(!std::indirectly_movable<const int*, const int *>); 44 static_assert( std::indirectly_movable<int*, int[2]>); 45 static_assert(!std::indirectly_movable<int[2], int*>); 46 static_assert(!std::indirectly_movable<int[2], int[2]>); 47 static_assert(!std::indirectly_movable<int(&)[2], int(&)[2]>); 48 static_assert(!std::indirectly_movable<int, int*>); 49 static_assert(!std::indirectly_movable<int, int>); 50 static_assert( std::indirectly_movable<Empty*, Empty*>); 51 static_assert( std::indirectly_movable<int*, IndirectlyMovableWithInt>); 52 static_assert(!std::indirectly_movable<Empty*, IndirectlyMovableWithInt>); 53 static_assert( std::indirectly_movable<int*, IndirectlyMovableWithInt>); 54 static_assert( std::indirectly_movable<MoveOnly*, MoveOnly*>); 55 static_assert(!std::indirectly_movable<MoveOnly*, const MoveOnly*>); 56 static_assert(!std::indirectly_movable<const MoveOnly*, const MoveOnly*>); 57 static_assert(!std::indirectly_movable<const MoveOnly*, MoveOnly*>); 58 static_assert( std::indirectly_movable<PointerTo<MoveOnly>, PointerTo<MoveOnly>>); 59 static_assert( std::indirectly_movable<MoveOnly*, PointerTo<MoveOnly>>); 60