blob: a051e297711556a67eb0f5f2b51fa5b99a47a9eb [file] [log] [blame]
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001//===----------------------------------------------------------------------===//
2//
Howard Hinnantf5256e12010-05-11 21:36:01 +00003// The LLVM Compiler Infrastructure
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004//
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
20int main()
21{
Howard Hinnant73d21a42010-09-04 23:28:19 +000022#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000023 {
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 Hinnant73d21a42010-09-04 23:28:19 +000054#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000055}