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