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 // <forward_list> 11 12 // iterator insert_after(const_iterator p, value_type&& v); 13 14 #include <forward_list> 15 #include <cassert> 16 17 #include "../../../MoveOnly.h" 18 19 int main() 20 { 21 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 22 { 23 typedef MoveOnly T; 24 typedef std::forward_list<T> C; 25 typedef C::iterator I; 26 C c; 27 I i = c.insert_after(c.cbefore_begin(), 0); 28 assert(i == c.begin()); 29 assert(c.front() == 0); 30 assert(c.front() == 0); 31 assert(distance(c.begin(), c.end()) == 1); 32 33 i = c.insert_after(c.cbegin(), 1); 34 assert(i == next(c.begin())); 35 assert(c.front() == 0); 36 assert(*next(c.begin()) == 1); 37 assert(distance(c.begin(), c.end()) == 2); 38 39 i = c.insert_after(next(c.cbegin()), 2); 40 assert(i == next(c.begin(), 2)); 41 assert(c.front() == 0); 42 assert(*next(c.begin()) == 1); 43 assert(*next(c.begin(), 2) == 2); 44 assert(distance(c.begin(), c.end()) == 3); 45 46 i = c.insert_after(c.cbegin(), 3); 47 assert(i == next(c.begin())); 48 assert(c.front() == 0); 49 assert(*next(c.begin(), 1) == 3); 50 assert(*next(c.begin(), 2) == 1); 51 assert(*next(c.begin(), 3) == 2); 52 assert(distance(c.begin(), c.end()) == 4); 53 } 54 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 55 } 56