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 // template <class InputIterator> 13 // forward_list(InputIterator first, InputIterator last, 14 // const allocator_type& a); 15 16 #include <forward_list> 17 #include <cassert> 18 #include <iterator> 19 20 #include "test_allocator.h" 21 #include "test_iterators.h" 22 #include "min_allocator.h" 23 24 int main() 25 { 26 { 27 typedef int T; 28 typedef test_allocator<T> A; 29 typedef std::forward_list<T, A> C; 30 typedef input_iterator<const T*> I; 31 const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; 32 C c(I(std::begin(t)), I(std::end(t)), A(13)); 33 unsigned n = 0; 34 for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n) 35 assert(*i == n); 36 assert(n == std::end(t) - std::begin(t)); 37 assert(c.get_allocator() == A(13)); 38 } 39 #if __cplusplus >= 201103L 40 { 41 typedef int T; 42 typedef min_allocator<T> A; 43 typedef std::forward_list<T, A> C; 44 typedef input_iterator<const T*> I; 45 const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; 46 C c(I(std::begin(t)), I(std::end(t)), A()); 47 unsigned n = 0; 48 for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n) 49 assert(*i == n); 50 assert(n == std::end(t) - std::begin(t)); 51 assert(c.get_allocator() == A()); 52 } 53 #endif 54 } 55