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