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// ADDITIONAL_COMPILE_FLAGS(has-fconstexpr-steps): -fconstexpr-steps=20000000
10// ADDITIONAL_COMPILE_FLAGS(has-fconstexpr-ops-limit): -fconstexpr-ops-limit=80000000
11
12// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
13
14// template<container-compatible-range<T> R>
15// constexpr iterator insert_range(const_iterator position, R&& rg); // C++23; constexpr since C++26
16
17#include <list>
18#include <type_traits>
19
20#include "../../insert_range_sequence_containers.h"
21#include "test_macros.h"
22
23// Tested cases:
24// - different kinds of insertions (inserting an {empty/one-element/mid-sized/long range} into an
25// {empty/one-element/full} container at the {beginning/middle/end});
26// - inserting move-only elements;
27// - an exception is thrown when copying the elements or when allocating new elements.
28TEST_CONSTEXPR_CXX26 bool test() {
29 static_assert(test_constraints_insert_range<std::list, int, double>());
30
31 for_all_iterators_and_allocators<int, const int*>([]<class Iter, class Sent, class Alloc>() {
32 test_sequence_insert_range<std::list<int, Alloc>, Iter, Sent>([](auto&&) {
33 // No additional validation to do.
34 });
35 });
36 test_sequence_insert_range_move_only<std::list>();
37
38 if (!TEST_IS_CONSTANT_EVALUATED) {
39 test_insert_range_exception_safety_throwing_copy<std::list>();
40 test_insert_range_exception_safety_throwing_allocator<std::list, int>();
41 }
42
43 return true;
44}
45
46int main(int, char**) {
47 assert(test());
48#if TEST_STD_VER >= 26
49 static_assert(test());
50#endif
51
52 return 0;
53}
54

source code of libcxx/test/std/containers/sequences/list/list.modifiers/insert_range.pass.cpp