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

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