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
10
11// <memory>
12//
13// Make sure we support iterators that return a BooleanTestable in the ranges:: algorithms
14// defined in <memory>.
15
16#include <memory>
17
18#include <ranges>
19
20#include "boolean_testable.h"
21
22using Value = StrictComparable<int>;
23using Iterator = StrictBooleanIterator<Value*>;
24using Range = std::ranges::subrange<Iterator>;
25
26void f(Iterator it, Range in, Range out, std::size_t n, Value const& val) {
27 // uninitialized_copy
28 {
29 std::ranges::uninitialized_copy(in, out);
30 std::ranges::uninitialized_copy(it, it, it, it);
31 }
32 // uninitialized_copy_n
33 { std::ranges::uninitialized_copy_n(it, n, it, it); }
34 // uninitialized_fill
35 {
36 std::ranges::uninitialized_fill(it, it, val);
37 std::ranges::uninitialized_fill(in, val);
38 }
39 // uninitialized_fill_n
40 { std::ranges::uninitialized_fill_n(it, n, val); }
41 // uninitialized_move
42 {
43 std::ranges::uninitialized_move(it, it, it, it);
44 std::ranges::uninitialized_move(in, out);
45 }
46 // uninitialized_move_n
47 { std::ranges::uninitialized_move_n(it, n, it, it); }
48 // uninitialized_default_construct
49 {
50 std::ranges::uninitialized_default_construct(it, it);
51 std::ranges::uninitialized_default_construct(in);
52 }
53 // uninitialized_default_construct_n
54 { std::ranges::uninitialized_default_construct_n(it, n); }
55 // uninitialized_value_construct
56 {
57 std::ranges::uninitialized_value_construct(it, it);
58 std::ranges::uninitialized_value_construct(in);
59 }
60 // uninitialized_value_construct_n
61 { std::ranges::uninitialized_value_construct_n(it, n); }
62 // destroy
63 {
64 std::ranges::destroy(it, it);
65 std::ranges::destroy(in);
66 }
67 // destroy_n
68 { std::ranges::destroy_n(it, n); }
69}
70

source code of libcxx/test/std/utilities/memory/specialized.algorithms/ranges_robust_against_nonbool.compile.pass.cpp