| 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 |
// <iterator> |
| 10 |
|
| 11 |
// template <InsertionContainer Cont> |
| 12 |
// insert_iterator<Cont> |
| 13 |
// inserter(Cont& x, Cont::iterator i); |
| 14 |
|
| 15 |
#include <cassert> |
| 16 |
#include <iterator> |
| 17 |
#include <vector> |
| 18 |
|
| 19 |
#include "test_macros.h" |
| 20 |
#include "nasty_containers.h" |
| 21 |
#include "test_constexpr_container.h" |
| 22 |
|
| 23 |
template <class C> |
| 24 |
TEST_CONSTEXPR_CXX20 bool |
| 25 |
test(C c) |
| 26 |
{ |
| 27 |
std::insert_iterator<C> i = std::inserter(c, c.end()); |
| 28 |
i = 0; |
| 29 |
assert(c.size() == 1); |
| 30 |
assert(c.back() == 0); |
| 31 |
return true; |
| 32 |
} |
| 33 |
|
| 34 |
int main(int, char**) |
| 35 |
{ |
| 36 |
test(std::vector<int>()); |
| 37 |
test(nasty_vector<int>()); |
| 38 |
#if TEST_STD_VER >= 20 |
| 39 |
test(ConstexprFixedCapacityDeque<int, 10>()); |
| 40 |
static_assert(test(ConstexprFixedCapacityDeque<int, 10>())); |
| 41 |
#endif |
| 42 |
return 0; |
| 43 |
} |