blob: f9b22304fe163279510ad5890dc8e233abe2908d [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// void assign(initializer_list<value_type> il);
13
14#include <forward_list>
15#include <cassert>
16#include <iterator>
17
18int main()
19{
Howard Hinnant73d21a42010-09-04 23:28:19 +000020#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000021 {
22 typedef int T;
23 typedef std::forward_list<T> C;
24 const T t1[] = {10, 11, 12, 13};
25 C c(std::begin(t1), std::end(t1));
26 c.assign({0, 1, 2, 3, 4, 5, 6, 7, 8, 9});
27 int n = 0;
28 for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
29 assert(*i == n);
30 assert(n == 10);
31 }
32 {
33 typedef int T;
34 typedef std::forward_list<T> C;
35 const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
36 C c(std::begin(t1), std::end(t1));
37 c.assign({10, 11, 12, 13});
38 int n = 0;
39 for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
40 assert(*i == 10+n);
41 assert(n == 4);
42 }
Howard Hinnant73d21a42010-09-04 23:28:19 +000043#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000044}