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