1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // <iterator> 11 12 // move_iterator 13 14 // move_iterator operator++(int); 15 // 16 // constexpr in C++17 17 18 #include <iterator> 19 #include <cassert> 20 21 #include "test_macros.h" 22 #include "test_iterators.h" 23 24 template <class It> 25 void 26 test(It i, It x) 27 { 28 std::move_iterator<It> r(i); 29 std::move_iterator<It> rr = r++; 30 assert(r.base() == x); 31 assert(rr.base() == i); 32 } 33 34 int main() 35 { 36 char s[] = "123"; 37 test(input_iterator<char*>(s), input_iterator<char*>(s+1)); 38 test(forward_iterator<char*>(s), forward_iterator<char*>(s+1)); 39 test(bidirectional_iterator<char*>(s), bidirectional_iterator<char*>(s+1)); 40 test(random_access_iterator<char*>(s), random_access_iterator<char*>(s+1)); 41 test(s, s+1); 42 43 #if TEST_STD_VER > 14 44 { 45 constexpr const char *p = "123456789"; 46 typedef std::move_iterator<const char *> MI; 47 constexpr MI it1 = std::make_move_iterator(p); 48 constexpr MI it2 = std::make_move_iterator(p+1); 49 static_assert(it1 != it2, ""); 50 constexpr MI it3 = std::make_move_iterator(p) ++; 51 static_assert(it1 == it3, ""); 52 static_assert(it2 != it3, ""); 53 } 54 #endif 55 } 56