xref: /llvm-project/libcxx/test/std/containers/sequences/list/list.modifiers/append_range.pass.cpp (revision ef70fe4d264d20abdd8476605650479a96a62071)
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 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
10 
11 // template<container-compatible-range<T> R>
12 //   constexpr void append_range(R&& rg); // C++23
13 
14 #include <list>
15 
16 #include "../../insert_range_sequence_containers.h"
17 #include "test_macros.h"
18 
19 // Tested cases:
20 // - different kinds of insertions (appending an {empty/one-element/mid-sized/long range} into an
21 //   {empty/one-element/full} container);
22 // - appending move-only elements;
23 // - an exception is thrown when copying the elements or when allocating new elements.
main(int,char **)24 int main(int, char**) {
25   static_assert(test_constraints_append_range<std::list, int, double>());
26 
27   for_all_iterators_and_allocators<int, const int*>([]<class Iter, class Sent, class Alloc>() {
28     test_sequence_append_range<std::list<int, Alloc>, Iter, Sent>([](auto&&) {
29       // No additional validation to do.
30     });
31   });
32   test_sequence_append_range_move_only<std::list>();
33 
34   test_append_range_exception_safety_throwing_copy<std::list>();
35   test_append_range_exception_safety_throwing_allocator<std::list, int>();
36 
37   return 0;
38 }
39