| 1 |
//===----------------------------------------------------------------------===// |
| 2 |
// |
| 3 |
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 |
// See https://llvm.org/LICENSE.txt for license information. |
| 5 |
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 |
// |
| 7 |
//===----------------------------------------------------------------------===// |
| 8 |
|
| 9 |
// <vector> |
| 10 |
|
| 11 |
// void pop_back(); |
| 12 |
|
| 13 |
#include <vector> |
| 14 |
#include <cassert> |
| 15 |
|
| 16 |
#include "test_macros.h" |
| 17 |
#include "test_allocator.h" |
| 18 |
#include "min_allocator.h" |
| 19 |
|
| 20 |
|
| 21 |
TEST_CONSTEXPR_CXX20 bool tests() |
| 22 |
{ |
| 23 |
{ |
| 24 |
std::vector<int> c; |
| 25 |
c.push_back(1); |
| 26 |
assert(c.size() == 1); |
| 27 |
c.pop_back(); |
| 28 |
assert(c.size() == 0); |
| 29 |
|
| 30 |
} |
| 31 |
#if TEST_STD_VER >= 11 |
| 32 |
{ |
| 33 |
std::vector<int, min_allocator<int>> c; |
| 34 |
c.push_back(1); |
| 35 |
assert(c.size() == 1); |
| 36 |
c.pop_back(); |
| 37 |
assert(c.size() == 0); |
| 38 |
} |
| 39 |
#endif |
| 40 |
|
| 41 |
{ // LWG 526 |
| 42 |
int arr[] = {0, 1, 2, 3, 4}; |
| 43 |
int sz = 5; |
| 44 |
std::vector<int> c(arr, arr+sz); |
| 45 |
while (c.size() < c.capacity()) |
| 46 |
c.push_back(sz++); |
| 47 |
c.push_back(c.front()); |
| 48 |
assert(c.back() == 0); |
| 49 |
for (int i = 0; i < sz; ++i) |
| 50 |
assert(c[i] == i); |
| 51 |
} |
| 52 |
|
| 53 |
return true; |
| 54 |
} |
| 55 |
|
| 56 |
int main(int, char**) |
| 57 |
{ |
| 58 |
tests(); |
| 59 |
#if TEST_STD_VER > 17 |
| 60 |
static_assert(tests()); |
| 61 |
#endif |
| 62 |
return 0; |
| 63 |
} |