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 <FrontInsertionContainer Cont>
12 //   front_insert_iterator<Cont>
13 //   front_inserter(Cont& x); // constexpr in C++20
14 
15 #include <cassert>
16 #include <iterator>
17 #include <list>
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
test(C c)25 test(C c)
26 {
27     std::front_insert_iterator<C> i = std::front_inserter(c);
28     i = 3;
29     assert(c.size() == 1);
30     assert(c.front() == 3);
31     i = 4;
32     assert(c.size() == 2);
33     assert(c.front() == 4);
34     return true;
35 }
36 
main(int,char **)37 int main(int, char**)
38 {
39     test(std::list<int>());
40     test(nasty_list<int>());
41 #if TEST_STD_VER >= 20
42     test(ConstexprFixedCapacityDeque<int, 10>());
43     static_assert(test(ConstexprFixedCapacityDeque<int, 10>()));
44 #endif
45     return 0;
46 }
47