1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11
13 // template <class... Args> reference emplace_back(Args&&... args);
14 // return type is 'reference' in C++17; 'void' before
18 #include "test_macros.h"
19 #include "min_allocator.h"
21 TEST_CONSTEXPR_CXX20
bool tests()
24 typedef std::vector
<bool> C
;
27 typedef C::reference Ref
;
28 Ref r1
= c
.emplace_back();
29 assert(c
.size() == 1);
30 assert(c
.front() == false);
32 assert(c
.front() == true);
34 Ref r2
= c
.emplace_back(true);
35 assert(c
.size() == 2);
36 assert(c
.front() == false);
37 assert(c
.back() == true);
39 assert(c
.back() == false);
43 assert(c
.size() == 1);
44 assert(c
.front() == false);
46 assert(c
.size() == 2);
47 assert(c
.front() == false);
48 assert(c
.back() == true);
51 assert(c
.size() == 3);
52 assert(c
.front() == false);
54 assert(c
.back() == true);
57 typedef std::vector
<bool, min_allocator
<bool>> C
;
61 typedef C::reference Ref
;
62 Ref r1
= c
.emplace_back();
63 assert(c
.size() == 1);
64 assert(c
.front() == false);
66 assert(c
.front() == true);
68 Ref r2
= c
.emplace_back(true);
69 assert(c
.size() == 2);
70 assert(c
.front() == false);
71 assert(c
.back() == true);
73 assert(c
.back() == false);
77 assert(c
.size() == 1);
78 assert(c
.front() == false);
80 assert(c
.size() == 2);
81 assert(c
.front() == false);
82 assert(c
.back() == true);
85 assert(c
.size() == 3);
86 assert(c
.front() == false);
88 assert(c
.back() == true);
98 static_assert(tests());