libcxx

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

construct_iter_iter.pass.cpp (1311B)


      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 // <vector>
     11 
     12 // template <class InputIter> vector(InputIter first, InputIter last);
     13 
     14 #include <vector>
     15 #include <cassert>
     16 
     17 #include "min_allocator.h"
     18 
     19 void test_ctor_under_alloc() {
     20   int arr1[] = {42};
     21   int arr2[] = {1, 101, 42};
     22   {
     23     typedef std::vector<int, cpp03_allocator<int> > C;
     24     typedef C::allocator_type Alloc;
     25     {
     26       Alloc::construct_called = false;
     27       C v(arr1, arr1 + 1);
     28       assert(Alloc::construct_called);
     29     }
     30     {
     31       Alloc::construct_called = false;
     32       C v(arr2, arr2 + 3);
     33       assert(Alloc::construct_called);
     34     }
     35   }
     36   {
     37     typedef std::vector<int, cpp03_overload_allocator<int> > C;
     38     typedef C::allocator_type Alloc;
     39     {
     40       Alloc::construct_called = false;
     41       C v(arr1, arr1 + 1);
     42       assert(Alloc::construct_called);
     43     }
     44     {
     45       Alloc::construct_called = false;
     46       C v(arr2, arr2 + 3);
     47       assert(Alloc::construct_called);
     48     }
     49   }
     50 }
     51 
     52 int main() {
     53   test_ctor_under_alloc();
     54 }