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 prepend_range(R&& rg); // C++23; constexpr since C++26
13
14#include <list>
15#include <type_traits>
16
17#include "../../insert_range_sequence_containers.h"
18#include "test_macros.h"
19
20// Tested cases:
21// - different kinds of insertions (prepending an {empty/one-element/mid-sized/long range} into an
22// {empty/one-element/full} container);
23// - prepending move-only elements;
24// - an exception is thrown when copying the elements or when allocating new elements.
25TEST_CONSTEXPR_CXX26 bool test() {
26 static_assert(test_constraints_prepend_range<std::list, int, double>());
27
28 for_all_iterators_and_allocators<int, const int*>([]<class Iter, class Sent, class Alloc>() {
29 test_sequence_prepend_range<std::list<int, Alloc>, Iter, Sent>([](auto&&) {
30 // No additional validation to do.
31 });
32 });
33 test_sequence_prepend_range_move_only<std::list>();
34
35 if (!TEST_IS_CONSTANT_EVALUATED) {
36 test_prepend_range_exception_safety_throwing_copy<std::list>();
37 test_prepend_range_exception_safety_throwing_allocator<std::list, int>();
38 }
39
40 return true;
41}
42
43int main(int, char**) {
44 assert(test());
45#if TEST_STD_VER >= 26
46 static_assert(test());
47#endif
48
49 return 0;
50}
51

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