libcxx

libcxx mirror with random patches
git clone https://git.neptards.moe/neptards/libcxx.git
Log | Files | Refs

assign_initializer_list.pass.cpp (1017B)


      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 // UNSUPPORTED: c++98, c++03
     11 
     12 // <list>
     13 
     14 // void assign(initializer_list<value_type> il);
     15 
     16 #include <list>
     17 #include <cassert>
     18 
     19 #include "min_allocator.h"
     20 
     21 int main()
     22 {
     23     {
     24     std::list<int> d;
     25     d.assign({3, 4, 5, 6});
     26     assert(d.size() == 4);
     27     std::list<int>::iterator i = d.begin();
     28     assert(*i++ == 3);
     29     assert(*i++ == 4);
     30     assert(*i++ == 5);
     31     assert(*i++ == 6);
     32     }
     33     {
     34     std::list<int, min_allocator<int>> d;
     35     d.assign({3, 4, 5, 6});
     36     assert(d.size() == 4);
     37     std::list<int, min_allocator<int>>::iterator i = d.begin();
     38     assert(*i++ == 3);
     39     assert(*i++ == 4);
     40     assert(*i++ == 5);
     41     assert(*i++ == 6);
     42     }
     43 }