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 // <iterator> 10 11 // move_iterator 12 13 // template <class U> 14 // requires HasConstructor<Iter, const U&> 15 // move_iterator(const move_iterator<U> &u); 16 // 17 // constexpr in C++17 18 19 #include <iterator> 20 #include <cassert> 21 22 #include "test_macros.h" 23 #include "test_iterators.h" 24 25 template <class It, class U> 26 void test(U u)27test(U u) 28 { 29 const std::move_iterator<U> r2(u); 30 std::move_iterator<It> r1 = r2; 31 assert(base(r1.base()) == base(u)); 32 } 33 34 struct Base {}; 35 struct Derived : Base {}; 36 main(int,char **)37int main(int, char**) 38 { 39 Derived d; 40 41 test<cpp17_input_iterator<Base*> >(cpp17_input_iterator<Derived*>(&d)); 42 test<forward_iterator<Base*> >(forward_iterator<Derived*>(&d)); 43 test<bidirectional_iterator<Base*> >(bidirectional_iterator<Derived*>(&d)); 44 test<random_access_iterator<const Base*> >(random_access_iterator<Derived*>(&d)); 45 test<Base*>(&d); 46 47 #if TEST_STD_VER > 14 48 { 49 constexpr const Derived *p = nullptr; 50 constexpr std::move_iterator<const Derived *> it1 = std::make_move_iterator(p); 51 constexpr std::move_iterator<const Base *> it2(it1); 52 static_assert(it2.base() == p); 53 } 54 #endif 55 56 return 0; 57 } 58