Dan Albert | 287553d | 2017-02-16 10:47:51 -0800 | [diff] [blame] | 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(initializer_list<value_type> il); |
| 13 | |
| 14 | #include <vector> |
| 15 | #include <cassert> |
| 16 | |
| 17 | #include "min_allocator.h" |
| 18 | #include "asan_testing.h" |
| 19 | |
| 20 | template <typename Vec> |
| 21 | void test ( Vec &v ) |
| 22 | { |
| 23 | #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS |
| 24 | v.assign({3, 4, 5, 6}); |
| 25 | assert(v.size() == 4); |
| 26 | assert(is_contiguous_container_asan_correct(v)); |
| 27 | assert(v[0] == 3); |
| 28 | assert(v[1] == 4); |
| 29 | assert(v[2] == 5); |
| 30 | assert(v[3] == 6); |
| 31 | #endif |
| 32 | } |
| 33 | |
| 34 | int main() |
| 35 | { |
| 36 | { |
| 37 | typedef std::vector<int> V; |
| 38 | V d1; |
| 39 | V d2; |
| 40 | d2.reserve(10); // no reallocation during assign. |
| 41 | test(d1); |
| 42 | test(d2); |
| 43 | } |
| 44 | |
| 45 | #if __cplusplus >= 201103L |
| 46 | { |
| 47 | typedef std::vector<int, min_allocator<int>> V; |
| 48 | V d1; |
| 49 | V d2; |
| 50 | d2.reserve(10); // no reallocation during assign. |
| 51 | test(d1); |
| 52 | test(d2); |
| 53 | } |
| 54 | #endif |
| 55 | } |