[libcxx-commits] [libcxx] ead7302 - [libc++][ranges] Implement `ranges::generate{, _n}`.
Konstantin Varlamov via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Jul 26 15:50:40 PDT 2022
Author: Konstantin Varlamov
Date: 2022-07-26T15:50:32-07:00
New Revision: ead7302bbb148df2f53d028e1a446f5437bac916
URL: https://github.com/llvm/llvm-project/commit/ead7302bbb148df2f53d028e1a446f5437bac916
DIFF: https://github.com/llvm/llvm-project/commit/ead7302bbb148df2f53d028e1a446f5437bac916.diff
LOG: [libc++][ranges] Implement `ranges::generate{,_n}`.
Differential Revision: https://reviews.llvm.org/D130552
Added:
Modified:
libcxx/docs/Status/RangesAlgorithms.csv
libcxx/include/__algorithm/ranges_generate.h
libcxx/include/__algorithm/ranges_generate_n.h
libcxx/include/algorithm
libcxx/test/std/algorithms/alg.modifying.operations/alg.generate/ranges_generate.pass.cpp
libcxx/test/std/algorithms/alg.modifying.operations/alg.generate/ranges_generate_n.pass.cpp
libcxx/test/std/algorithms/ranges_robust_against_dangling.pass.cpp
libcxx/test/std/algorithms/ranges_robust_against_omitting_invoke.pass.cpp
libcxx/test/std/algorithms/ranges_robust_against_proxy_iterators.pass.cpp
libcxx/test/std/library/description/conventions/customization.point.object/niebloid.compile.pass.cpp
Removed:
################################################################################
diff --git a/libcxx/docs/Status/RangesAlgorithms.csv b/libcxx/docs/Status/RangesAlgorithms.csv
index 40ebffa1adf6c..35db0ad64ae81 100644
--- a/libcxx/docs/Status/RangesAlgorithms.csv
+++ b/libcxx/docs/Status/RangesAlgorithms.csv
@@ -45,8 +45,8 @@ Write,move_backward,Nikolas Klauser,`D126616 <https://llvm.org/D126616>`_,✅
Write,fill,Nikolas Klauser,`D123462 <https://llvm.org/D123462>`_,✅
Write,fill_n,Nikolas Klauser,`D123462 <https://llvm.org/D123462>`_,✅
Write,transform,Nikolas Klauser,`D122173 <https://llvm.org/D122173>`_,✅
-Write,generate,Nikolas Klauser,n/a,Not started
-Write,generate_n,Nikolas Klauser,n/a,Not started
+Write,generate,Konstantin Varlamov,`D130552 <https://llvm.org/D130552>`_,✅
+Write,generate_n,Konstantin Varlamov,`D130552 <https://llvm.org/D130552>`_,✅
Write,remove_copy,Nikolas Klauser,n/a,Not started
Write,remove_copy_if,Nikolas Klauser,n/a,Not started
Write,replace,Nikolas Klauser,`D126283 <https://llvm.org/D126283>`_,✅
diff --git a/libcxx/include/__algorithm/ranges_generate.h b/libcxx/include/__algorithm/ranges_generate.h
index c23645e6d906d..149296574d803 100644
--- a/libcxx/include/__algorithm/ranges_generate.h
+++ b/libcxx/include/__algorithm/ranges_generate.h
@@ -9,21 +9,15 @@
#ifndef _LIBCPP___ALGORITHM_RANGES_GENERATE_H
#define _LIBCPP___ALGORITHM_RANGES_GENERATE_H
-#include <__algorithm/generate.h>
-#include <__algorithm/make_projected.h>
#include <__concepts/constructible.h>
#include <__concepts/invocable.h>
#include <__config>
-#include <__functional/identity.h>
#include <__functional/invoke.h>
-#include <__functional/ranges_operations.h>
#include <__iterator/concepts.h>
#include <__iterator/iterator_traits.h>
-#include <__iterator/projected.h>
#include <__ranges/access.h>
#include <__ranges/concepts.h>
#include <__ranges/dangling.h>
-#include <__utility/forward.h>
#include <__utility/move.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -39,22 +33,28 @@ namespace __generate {
struct __fn {
+ template <class _OutIter, class _Sent, class _Func>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ static _OutIter __generate_fn_impl(_OutIter __first, _Sent __last, _Func& __gen) {
+ for (; __first != __last; ++__first) {
+ *__first = __gen();
+ }
+
+ return __first;
+ }
+
template <input_or_output_iterator _OutIter, sentinel_for<_OutIter> _Sent, copy_constructible _Func>
requires invocable<_Func&> && indirectly_writable<_OutIter, invoke_result_t<_Func&>>
_LIBCPP_HIDE_FROM_ABI constexpr
_OutIter operator()(_OutIter __first, _Sent __last, _Func __gen) const {
- // TODO: implement
- (void)__first; (void)__last; (void)__gen;
- return {};
+ return __generate_fn_impl(std::move(__first), std::move(__last), __gen);
}
template <class _Range, copy_constructible _Func>
requires invocable<_Func&> && output_range<_Range, invoke_result_t<_Func&>>
_LIBCPP_HIDE_FROM_ABI constexpr
borrowed_iterator_t<_Range> operator()(_Range&& __range, _Func __gen) const {
- // TODO: implement
- (void)__range; (void)__gen;
- return {};
+ return __generate_fn_impl(ranges::begin(__range), ranges::end(__range), __gen);
}
};
diff --git a/libcxx/include/__algorithm/ranges_generate_n.h b/libcxx/include/__algorithm/ranges_generate_n.h
index 7bde5fb4e5795..63f466cecdd7c 100644
--- a/libcxx/include/__algorithm/ranges_generate_n.h
+++ b/libcxx/include/__algorithm/ranges_generate_n.h
@@ -9,21 +9,16 @@
#ifndef _LIBCPP___ALGORITHM_RANGES_GENERATE_N_H
#define _LIBCPP___ALGORITHM_RANGES_GENERATE_N_H
-#include <__algorithm/generate_n.h>
-#include <__algorithm/make_projected.h>
#include <__concepts/constructible.h>
#include <__concepts/invocable.h>
#include <__config>
#include <__functional/identity.h>
#include <__functional/invoke.h>
-#include <__functional/ranges_operations.h>
#include <__iterator/concepts.h>
#include <__iterator/incrementable_traits.h>
#include <__iterator/iterator_traits.h>
-#include <__iterator/projected.h>
#include <__ranges/access.h>
#include <__ranges/concepts.h>
-#include <__utility/forward.h>
#include <__utility/move.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -43,9 +38,12 @@ struct __fn {
requires invocable<_Func&> && indirectly_writable<_OutIter, invoke_result_t<_Func&>>
_LIBCPP_HIDE_FROM_ABI constexpr
_OutIter operator()(_OutIter __first, iter_
diff erence_t<_OutIter> __n, _Func __gen) const {
- // TODO: implement
- (void)__first; (void)__n; (void)__gen;
- return {};
+ for (; __n > 0; --__n) {
+ *__first = __gen();
+ ++__first;
+ }
+
+ return __first;
}
};
diff --git a/libcxx/include/algorithm b/libcxx/include/algorithm
index 5958ad1a95af0..30b04e155bac0 100644
--- a/libcxx/include/algorithm
+++ b/libcxx/include/algorithm
@@ -380,6 +380,18 @@ namespace ranges {
template<class T, output_iterator<const T&> O>
constexpr O ranges::fill_n(O first, iter_
diff erence_t<O> n, const T& value); // since C++20
+ template<input_or_output_iterator O, sentinel_for<O> S, copy_constructible F>
+ requires invocable<F&> && indirectly_writable<O, invoke_result_t<F&>>
+ constexpr O generate(O first, S last, F gen); // Since C++20
+
+ template<class R, copy_constructible F>
+ requires invocable<F&> && output_range<R, invoke_result_t<F&>>
+ constexpr borrowed_iterator_t<R> generate(R&& r, F gen); // Since C++20
+
+ template<input_or_output_iterator O, copy_constructible F>
+ requires invocable<F&> && indirectly_writable<O, invoke_result_t<F&>>
+ constexpr O generate_n(O first, iter_
diff erence_t<O> n, F gen); // Since C++20
+
template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2>
@@ -1575,6 +1587,8 @@ template <class BidirectionalIterator, class Compare>
#include <__algorithm/ranges_find_if_not.h>
#include <__algorithm/ranges_for_each.h>
#include <__algorithm/ranges_for_each_n.h>
+#include <__algorithm/ranges_generate.h>
+#include <__algorithm/ranges_generate_n.h>
#include <__algorithm/ranges_includes.h>
#include <__algorithm/ranges_is_partitioned.h>
#include <__algorithm/ranges_is_sorted.h>
diff --git a/libcxx/test/std/algorithms/alg.modifying.operations/alg.generate/ranges_generate.pass.cpp b/libcxx/test/std/algorithms/alg.modifying.operations/alg.generate/ranges_generate.pass.cpp
index f8e19cd0e7667..9b95892418f64 100644
--- a/libcxx/test/std/algorithms/alg.modifying.operations/alg.generate/ranges_generate.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.modifying.operations/alg.generate/ranges_generate.pass.cpp
@@ -24,16 +24,176 @@
#include <concepts>
#include <functional>
#include <ranges>
+#include <utility>
#include "almost_satisfies_types.h"
#include "test_iterators.h"
-// TODO: SFINAE tests.
+struct IntGen {
+ int operator()() const;
+};
+
+struct UncopyableGen {
+ UncopyableGen(const UncopyableGen&) = delete;
+ int operator()() const;
+};
+static_assert(!std::copy_constructible<UncopyableGen>);
+static_assert(std::invocable<UncopyableGen>);
+
+struct UninvocableGen {
+};
+static_assert(std::copy_constructible<UninvocableGen>);
+static_assert(!std::invocable<UninvocableGen>);
+
+struct IntPtrGen {
+ int* operator()() const;
+};
+
+// Test constraints of the (iterator, sentinel) overload.
+// ======================================================
+
+template <class Iter = int*, class Sent = int*, class Gen = IntGen>
+concept HasGenerateIter =
+ requires(Iter&& iter, Sent&& sent, Gen&& gen) {
+ std::ranges::generate(std::forward<Iter>(iter), std::forward<Sent>(sent), std::forward<Gen>(gen));
+ };
+
+static_assert(HasGenerateIter<int*, int*, IntGen>);
+
+// !input_or_output_iterator<O>
+static_assert(!HasGenerateIter<InputIteratorNotInputOrOutputIterator>);
+
+// !sentinel_for<S, O>
+static_assert(!HasGenerateIter<int*, SentinelForNotSemiregular>);
+static_assert(!HasGenerateIter<int*, SentinelForNotWeaklyEqualityComparableWith>);
+
+// !copy_constructible<F>
+static_assert(!HasGenerateIter<int*, int*, UncopyableGen>);
+
+// !invocable<F&>
+static_assert(!HasGenerateIter<int*, int*, UninvocableGen>);
+
+// !indirectly_writable<O, invoke_result_t<F&>>
+static_assert(!HasGenerateIter<int*, int*, IntPtrGen>);
+
+// Test constraints of the (range) overload.
+// =========================================
+
+template <class Range, class Gen = IntGen>
+concept HasGenerateRange =
+ requires(Range&& range, Gen&& gen) {
+ std::ranges::generate(std::forward<Range>(range), std::forward<Gen>(gen));
+ };
+
+template <class T>
+using R = UncheckedRange<T>;
+
+static_assert(HasGenerateRange<R<int*>, IntGen>);
+
+// !copy_constructible<F>
+static_assert(!HasGenerateRange<R<int*>, UncopyableGen>);
+
+// !invocable<F&>
+static_assert(!HasGenerateRange<R<int*>, UninvocableGen>);
+
+// !output_range<R, invoke_result_t<F&>>
+static_assert(!HasGenerateRange<InputRangeNotInputOrOutputIterator>);
+static_assert(!HasGenerateRange<R<int*>, IntPtrGen>);
+
+template <class Iter, class Sent, size_t N, class Gen>
+constexpr void test_one(const std::array<int, N> input, Gen gen, std::array<int, N> expected) {
+ { // (iterator, sentinel) overload.
+ auto in = input;
+ auto begin = Iter(in.data());
+ auto end = Sent(Iter(in.data() + in.size()));
+
+ std::same_as<Iter> decltype(auto) result = std::ranges::generate(std::move(begin), std::move(end), gen);
+ assert(base(result) == in.data() + in.size());
+ assert(in == expected);
+ }
+
+ { // (range) overload.
+ auto in = input;
+ auto begin = Iter(in.data());
+ auto end = Sent(Iter(in.data() + in.size()));
+ auto range = std::ranges::subrange(std::move(begin), std::move(end));
+
+ // For some reason `ranges::generate` accepts both input and output iterators but only output (not input) ranges.
+ if constexpr (std::ranges::output_range<decltype(range), std::invoke_result_t<Gen&>>) {
+ std::same_as<Iter> decltype(auto) result = std::ranges::generate(std::move(range), gen);
+ assert(base(result) == in.data() + in.size());
+ assert(in == expected);
+ }
+ }
+}
+
+template <class Iter, class Sent>
+constexpr void test_iter_sent() {
+ auto gen = [ctr = 1] () mutable { return ctr++; };
+
+ // Empty sequence.
+ test_one<Iter, Sent, 0>({}, gen, {});
+ // 1-element sequence.
+ test_one<Iter, Sent>(std::array{-10}, gen, {1});
+ // Longer sequence.
+ test_one<Iter, Sent>(std::array<int, 5>{}, gen, {1, 2, 3, 4, 5});
+}
+
+template <class Iter>
+constexpr void test_iter() {
+ if constexpr (std::sentinel_for<Iter, Iter>) {
+ test_iter_sent<Iter, Iter>();
+ }
+ test_iter_sent<Iter, sentinel_wrapper<Iter>>();
+}
+
+constexpr void test_iterators() {
+ test_iter<cpp17_input_iterator<int*>>();
+ test_iter<cpp20_input_iterator<int*>>();
+ test_iter<cpp17_output_iterator<int*>>();
+ test_iter<cpp20_output_iterator<int*>>();
+ test_iter<forward_iterator<int*>>();
+ test_iter<bidirectional_iterator<int*>>();
+ test_iter<random_access_iterator<int*>>();
+ test_iter<contiguous_iterator<int*>>();
+ test_iter<int*>();
+}
constexpr bool test() {
- // TODO: main tests.
- // TODO: A custom comparator works.
- // TODO: A custom projection works.
+ test_iterators();
+
+ { // Complexity: exactly N evaluations of `gen()` and assignments.
+ struct AssignedOnce {
+ bool assigned = false;
+ constexpr AssignedOnce& operator=(const AssignedOnce&) {
+ assert(!assigned);
+ assigned = true;
+ return *this;
+ }
+ };
+
+ { // (iterator, sentinel) overload.
+ int gen_invocations = 0;
+ auto gen = [&gen_invocations] { ++gen_invocations; return AssignedOnce(); };
+ constexpr size_t N = 10;
+ std::array<AssignedOnce, N> in;
+
+ std::ranges::generate(in.begin(), in.end(), gen);
+ assert(std::ranges::all_of(in, &AssignedOnce::assigned));
+ assert(gen_invocations == N);
+ }
+
+ { // (range) overload.
+ int gen_invocations = 0;
+ auto gen = [&gen_invocations] { ++gen_invocations; return AssignedOnce(); };
+ constexpr size_t N = 10;
+ std::array<AssignedOnce, N> in;
+
+ std::ranges::generate(in, gen);
+ assert(std::ranges::all_of(in, &AssignedOnce::assigned));
+ assert(gen_invocations == N);
+ }
+ }
return true;
}
diff --git a/libcxx/test/std/algorithms/alg.modifying.operations/alg.generate/ranges_generate_n.pass.cpp b/libcxx/test/std/algorithms/alg.modifying.operations/alg.generate/ranges_generate_n.pass.cpp
index 10abac9107286..45377d452b7e3 100644
--- a/libcxx/test/std/algorithms/alg.modifying.operations/alg.generate/ranges_generate_n.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.modifying.operations/alg.generate/ranges_generate_n.pass.cpp
@@ -24,12 +24,113 @@
#include "almost_satisfies_types.h"
#include "test_iterators.h"
-// TODO: SFINAE tests.
+struct IntGen {
+ int operator()() const;
+};
+
+struct UncopyableGen {
+ UncopyableGen(const UncopyableGen&) = delete;
+ int operator()() const;
+};
+static_assert(!std::copy_constructible<UncopyableGen>);
+static_assert(std::invocable<UncopyableGen>);
+
+struct UninvocableGen {
+};
+static_assert(std::copy_constructible<UninvocableGen>);
+static_assert(!std::invocable<UninvocableGen>);
+
+struct IntPtrGen {
+ int* operator()() const;
+};
+
+// Test type constraints.
+// ======================================================
+
+template <class Iter = int*, class Gen = IntGen>
+concept HasGenerateNIter =
+ requires(Iter&& iter, Gen&& gen) {
+ std::ranges::generate_n(std::forward<Iter>(iter), 0, std::forward<Gen>(gen));
+ };
+
+static_assert(HasGenerateNIter<int*, IntGen>);
+
+// !input_or_output_iterator<O>
+static_assert(!HasGenerateNIter<InputIteratorNotInputOrOutputIterator>);
+
+// !copy_constructible<F>
+static_assert(!HasGenerateNIter<int*, UncopyableGen>);
+
+// !invocable<F&>
+static_assert(!HasGenerateNIter<int*, UninvocableGen>);
+
+// !indirectly_writable<O, invoke_result_t<F&>>
+static_assert(!HasGenerateNIter<int*, IntPtrGen>);
+
+template <class Iter, size_t N, class Gen>
+constexpr void test_one(std::array<int, N> in, size_t n, Gen gen, std::array<int, N> expected) {
+ assert(n <= N);
+
+ auto begin = Iter(in.data());
+
+ std::same_as<Iter> decltype(auto) result = std::ranges::generate_n(std::move(begin), n, gen);
+ assert(base(result) == in.data() + n);
+ assert(in == expected);
+}
+
+template <class Iter>
+constexpr void test_iter() {
+ auto gen = [ctr = 1] () mutable { return ctr++; };
+
+ // Empty sequence.
+ test_one<Iter, 0>({}, 0, gen, {});
+ // 1-element sequence, n = 0.
+ test_one<Iter>(std::array{-10}, 0, gen, {-10});
+ // 1-element sequence, n = 1.
+ test_one<Iter>(std::array{-10}, 1, gen, {1});
+ // Longer sequence, n = 3.
+ test_one<Iter>(std::array{-10, -20, -30, -40, -50}, 3, gen, {1, 2, 3, -40, -50});
+ // Longer sequence, n = 5.
+ test_one<Iter>(std::array<int, 5>{}, 5, gen, {1, 2, 3, 4, 5});
+}
+
+constexpr void test_iterators() {
+ test_iter<cpp17_input_iterator<int*>>();
+ test_iter<cpp20_input_iterator<int*>>();
+ test_iter<cpp17_output_iterator<int*>>();
+ test_iter<cpp20_output_iterator<int*>>();
+ test_iter<forward_iterator<int*>>();
+ test_iter<bidirectional_iterator<int*>>();
+ test_iter<random_access_iterator<int*>>();
+ test_iter<contiguous_iterator<int*>>();
+ test_iter<int*>();
+}
constexpr bool test() {
- // TODO: main tests.
- // TODO: A custom comparator works.
- // TODO: A custom projection works.
+ test_iterators();
+
+ { // Complexity: exactly N evaluations of `gen()` and assignments.
+ struct AssignedOnce {
+ bool assigned = false;
+ constexpr AssignedOnce& operator=(const AssignedOnce&) {
+ assert(!assigned);
+ assigned = true;
+ return *this;
+ }
+ };
+
+ int gen_invocations = 0;
+ auto gen = [&gen_invocations] { ++gen_invocations; return AssignedOnce(); };
+ constexpr size_t N1 = 10;
+ constexpr size_t N2 = N1 / 2;
+ std::array<AssignedOnce, N1> in;
+
+ auto result = std::ranges::generate_n(in.begin(), N2, gen);
+ assert(std::ranges::all_of(std::ranges::subrange(in.begin(), result), &AssignedOnce::assigned));
+ assert(std::ranges::none_of(std::ranges::subrange(result, in.end()), &AssignedOnce::assigned));
+ assert(gen_invocations == N2);
+ }
+
return true;
}
diff --git a/libcxx/test/std/algorithms/ranges_robust_against_dangling.pass.cpp b/libcxx/test/std/algorithms/ranges_robust_against_dangling.pass.cpp
index e474c65d49ae8..7e92e15d69010 100644
--- a/libcxx/test/std/algorithms/ranges_robust_against_dangling.pass.cpp
+++ b/libcxx/test/std/algorithms/ranges_robust_against_dangling.pass.cpp
@@ -92,7 +92,7 @@ constexpr bool test_all() {
auto unary_pred = [](int i) { return i > 0; };
auto binary_pred = [](int i, int j) { return i < j; };
- //auto gen = [] { return 42; };
+ auto gen = [] { return 42; };
std::array in = {1, 2, 3};
std::array in2 = {4, 5, 6};
@@ -145,7 +145,7 @@ constexpr bool test_all() {
dangling_both<binary_transform_result<dangling, dangling, bool*>>(
std::ranges::transform, in, in2, out_transform.begin(), binary_pred);
}
- //dangling_1st(std::ranges::generate, in, gen);
+ dangling_1st(std::ranges::generate, in, gen);
//dangling_1st<remove_copy_result<dangling, int*>>(std::ranges::remove_copy, in, out, x);
//dangling_1st<remove_copy_if_result<dangling, int*>>(std::ranges::remove_copy_if, in, out, unary_pred);
dangling_1st(std::ranges::replace, in, x, x);
diff --git a/libcxx/test/std/algorithms/ranges_robust_against_omitting_invoke.pass.cpp b/libcxx/test/std/algorithms/ranges_robust_against_omitting_invoke.pass.cpp
index 44a15208dd185..38ca7c2522ff2 100644
--- a/libcxx/test/std/algorithms/ranges_robust_against_omitting_invoke.pass.cpp
+++ b/libcxx/test/std/algorithms/ranges_robust_against_omitting_invoke.pass.cpp
@@ -128,8 +128,7 @@ constexpr bool test_all() {
std::array out_transform = {false, true, true};
test(std::ranges::transform, in, out_transform.begin(), &Foo::unary_pred, &Bar::val);
}
- //test(std::ranges::generate, in, &Bar::create);
- //std::ranges::generate_n(in.begin(), count, &Bar::create);
+ // Whether `ranges::generate{,_n}` invokes `gen` via `std::invoke` is not observable.
//test(std::ranges::remove_copy, in, out, x, &Bar::val);
//test(std::ranges::remove_copy_if, in, out, &Foo::unary_pred, &Bar::val);
// `replace*` algorithms only use the projection to compare the elements, not to write them.
diff --git a/libcxx/test/std/algorithms/ranges_robust_against_proxy_iterators.pass.cpp b/libcxx/test/std/algorithms/ranges_robust_against_proxy_iterators.pass.cpp
index b7d32b18b5b82..c4aa662978b93 100644
--- a/libcxx/test/std/algorithms/ranges_robust_against_proxy_iterators.pass.cpp
+++ b/libcxx/test/std/algorithms/ranges_robust_against_proxy_iterators.pass.cpp
@@ -70,7 +70,7 @@ constexpr void run_tests() {
auto unary_pred = [](const Proxy<T&>&) { return true; };
//auto binary_pred = [](const Proxy<T>&, const Proxy<T>&) { return return false; };
auto binary_func = [](const Proxy<T>&, const Proxy<T>&) -> Proxy<T> { return Proxy<T>(T()); };
- //auto gen = [] { return Proxy<T>(T{42}); };
+ auto gen = [] { return Proxy<T>(T{42}); };
test(std::ranges::any_of, in, unary_pred);
test(std::ranges::all_of, in, unary_pred);
@@ -122,8 +122,8 @@ constexpr void run_tests() {
test(std::ranges::transform, in, out, std::identity{});
test(std::ranges::transform, in, in2, out, binary_func);
}
- //test(std::ranges::generate, in, gen);
- //std::ranges::generate_n(in.begin(), count, gen);
+ test(std::ranges::generate, in, gen);
+ std::ranges::generate_n(in.begin(), count, gen);
if constexpr (std::copyable<T>) {
//test(std::ranges::remove_copy, in, out, x);
//test(std::ranges::remove_copy_if, in, out, unary_pred);
diff --git a/libcxx/test/std/library/description/conventions/customization.point.object/niebloid.compile.pass.cpp b/libcxx/test/std/library/description/conventions/customization.point.object/niebloid.compile.pass.cpp
index e8861c37ab2c8..9aa8024d86305 100644
--- a/libcxx/test/std/library/description/conventions/customization.point.object/niebloid.compile.pass.cpp
+++ b/libcxx/test/std/library/description/conventions/customization.point.object/niebloid.compile.pass.cpp
@@ -55,7 +55,7 @@ int *p;
int a[10];
auto odd = [](int x) { return x % 2 != 0; };
auto triple = [](int x) { return 3*x; };
-//auto gen = [] { return 42; };
+auto gen = [] { return 42; };
//auto plus = [](int x, int y) { return x == y; };
std::mt19937 g;
@@ -84,8 +84,8 @@ static_assert(test(std::ranges::find_if, a, odd));
static_assert(test(std::ranges::find_if_not, a, odd));
static_assert(test(std::ranges::for_each, a, odd));
static_assert(test(std::ranges::for_each_n, a, 10, odd));
-//static_assert(test(std::ranges::generate, a, gen));
-//static_assert(test(std::ranges::generate_n, a, 10, gen));
+static_assert(test(std::ranges::generate, a, gen));
+static_assert(test(std::ranges::generate_n, a, 10, gen));
static_assert(test(std::ranges::includes, a, a));
//static_assert(test(std::ranges::inplace_merge, a, a+5));
//static_assert(test(std::ranges::is_heap, a));
More information about the libcxx-commits
mailing list