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 // void assign(size_type n, const_reference v); 13 14 #include <vector> 15 #include <algorithm> 16 #include <cassert> 17 #include <iostream> 18 19 #include "min_allocator.h" 20 #include "asan_testing.h" 21 is6(int x)22bool is6(int x) { return x == 6; } 23 24 template <typename Vec> test(Vec & v)25void test ( Vec &v ) 26 { 27 v.assign(5, 6); 28 assert(v.size() == 5); 29 assert(is_contiguous_container_asan_correct(v)); 30 assert(std::all_of(v.begin(), v.end(), is6)); 31 } 32 main()33int main() 34 { 35 { 36 typedef std::vector<int> V; 37 V d1; 38 V d2; 39 d2.reserve(10); // no reallocation during assign. 40 test(d1); 41 test(d2); 42 } 43 44 #if __cplusplus >= 201103L 45 { 46 typedef std::vector<int, min_allocator<int>> V; 47 V d1; 48 V d2; 49 d2.reserve(10); // no reallocation during assign. 50 test(d1); 51 test(d2); 52 } 53 #endif 54 } 55