assign_op_init.pass.cpp revision 6046aced820aaab4f14f2026531dd11d10690691
1//===----------------------------------------------------------------------===//
2//
3//                     The LLVM Compiler Infrastructure
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// forward_list& operator=(initializer_list<value_type> il);
13
14#include <forward_list>
15#include <cassert>
16#include <iterator>
17
18int main()
19{
20#ifdef _LIBCPP_MOVE
21    {
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 = {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 = {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    }
43#endif  // _LIBCPP_MOVE
44}
45