1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. 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 { 20 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS 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 } 43 #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS 44 } 45