Home | History | Annotate | Download | only in forwardlist.cons
      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 //     void assign(InputIterator first, InputIterator last);
     14 
     15 #include <forward_list>
     16 #include <cassert>
     17 #include <iterator>
     18 
     19 #include "test_iterators.h"
     20 
     21 int main()
     22 {
     23     {
     24         typedef int T;
     25         typedef std::forward_list<T> C;
     26         const T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
     27         const T t1[] = {10, 11, 12, 13};
     28         C c(std::begin(t1), std::end(t1));
     29         typedef input_iterator<const T*> I;
     30         c.assign(I(std::begin(t0)), I(std::end(t0)));
     31         int n = 0;
     32         for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
     33             assert(*i == n);
     34         assert(n == 10);
     35     }
     36     {
     37         typedef int T;
     38         typedef std::forward_list<T> C;
     39         const T t0[] = {10, 11, 12, 13};
     40         const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
     41         C c(std::begin(t1), std::end(t1));
     42         typedef input_iterator<const T*> I;
     43         c.assign(I(std::begin(t0)), I(std::end(t0)));
     44         int n = 0;
     45         for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
     46             assert(*i == 10+n);
     47         assert(n == 4);
     48     }
     49 }
     50