Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
Howard Hinnant | f5256e1 | 2010-05-11 21:36:01 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | // <forward_list> |
| 11 | |
| 12 | // template <class... Args> |
| 13 | // iterator emplace_after(const_iterator p, Args&&... args); |
| 14 | |
| 15 | #include <forward_list> |
| 16 | #include <cassert> |
| 17 | |
| 18 | #include "../../../Emplaceable.h" |
| 19 | |
| 20 | int main() |
| 21 | { |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame^] | 22 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 23 | { |
| 24 | typedef Emplaceable T; |
| 25 | typedef std::forward_list<T> C; |
| 26 | typedef C::iterator I; |
| 27 | C c; |
| 28 | I i = c.emplace_after(c.cbefore_begin()); |
| 29 | assert(i == c.begin()); |
| 30 | assert(c.front() == Emplaceable()); |
| 31 | assert(distance(c.begin(), c.end()) == 1); |
| 32 | |
| 33 | i = c.emplace_after(c.cbegin(), 1, 2.5); |
| 34 | assert(i == next(c.begin())); |
| 35 | assert(c.front() == Emplaceable()); |
| 36 | assert(*next(c.begin()) == Emplaceable(1, 2.5)); |
| 37 | assert(distance(c.begin(), c.end()) == 2); |
| 38 | |
| 39 | i = c.emplace_after(next(c.cbegin()), 2, 3.5); |
| 40 | assert(i == next(c.begin(), 2)); |
| 41 | assert(c.front() == Emplaceable()); |
| 42 | assert(*next(c.begin()) == Emplaceable(1, 2.5)); |
| 43 | assert(*next(c.begin(), 2) == Emplaceable(2, 3.5)); |
| 44 | assert(distance(c.begin(), c.end()) == 3); |
| 45 | |
| 46 | i = c.emplace_after(c.cbegin(), 3, 4.5); |
| 47 | assert(i == next(c.begin())); |
| 48 | assert(c.front() == Emplaceable()); |
| 49 | assert(*next(c.begin(), 1) == Emplaceable(3, 4.5)); |
| 50 | assert(*next(c.begin(), 2) == Emplaceable(1, 2.5)); |
| 51 | assert(*next(c.begin(), 3) == Emplaceable(2, 3.5)); |
| 52 | assert(distance(c.begin(), c.end()) == 4); |
| 53 | } |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame^] | 54 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 55 | } |