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 | // void assign(initializer_list<value_type> il); |
| 13 | |
| 14 | #include <forward_list> |
| 15 | #include <cassert> |
| 16 | #include <iterator> |
| 17 | |
| 18 | int main() |
| 19 | { |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame^] | 20 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 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.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 Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame^] | 43 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 44 | } |