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 #include "min_allocator.h" 19 20 int main() 21 { 22 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS 23 { 24 typedef int T; 25 typedef std::forward_list<T> C; 26 const T t1[] = {10, 11, 12, 13}; 27 C c(std::begin(t1), std::end(t1)); 28 c.assign({0, 1, 2, 3, 4, 5, 6, 7, 8, 9}); 29 int n = 0; 30 for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n) 31 assert(*i == n); 32 assert(n == 10); 33 } 34 { 35 typedef int T; 36 typedef std::forward_list<T> C; 37 const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; 38 C c(std::begin(t1), std::end(t1)); 39 c.assign({10, 11, 12, 13}); 40 int n = 0; 41 for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n) 42 assert(*i == 10+n); 43 assert(n == 4); 44 } 45 #if __cplusplus >= 201103L 46 { 47 typedef int T; 48 typedef std::forward_list<T, min_allocator<T>> C; 49 const T t1[] = {10, 11, 12, 13}; 50 C c(std::begin(t1), std::end(t1)); 51 c.assign({0, 1, 2, 3, 4, 5, 6, 7, 8, 9}); 52 int n = 0; 53 for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n) 54 assert(*i == n); 55 assert(n == 10); 56 } 57 { 58 typedef int T; 59 typedef std::forward_list<T, min_allocator<T>> C; 60 const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; 61 C c(std::begin(t1), std::end(t1)); 62 c.assign({10, 11, 12, 13}); 63 int n = 0; 64 for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n) 65 assert(*i == 10+n); 66 assert(n == 4); 67 } 68 #endif 69 #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS 70 } 71