Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions stl/inc/algorithm
Original file line number Diff line number Diff line change
Expand Up @@ -1557,12 +1557,6 @@ namespace ranges {
_Seek_wrapped(_First, _STD move(_UFirst));
return {_STD move(_First), _STD move(_Result)};
}

template <input_range _Rng, weakly_incrementable _Out>
requires indirectly_copyable<iterator_t<_Rng>, _Out>
constexpr copy_n_result<borrowed_iterator_t<_Rng>, _Out> operator()(_Rng&& _Range, _Out _Result) const {
return (*this)(_RANGES begin(_Range), _RANGES end(_Range), _STD move(_Result));
}
// clang-format on
};

Expand Down
45 changes: 20 additions & 25 deletions tests/std/tests/P0896R4_ranges_alg_copy_n/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,29 @@

#include <range_algorithm_support.hpp>

constexpr void smoke_test() {
using ranges::copy_n, ranges::copy_n_result, ranges::iterator_t;
using std::same_as;

// Validate that copy_n_result aliases in_out_result
STATIC_ASSERT(same_as<copy_n_result<int, double>, ranges::in_out_result<int, double>>);

int const input[] = {13, 42, 1729};
int output[] = {-1, -1, -1};
basic_borrowed_range wrapped_input{input};
auto result = copy_n(wrapped_input.begin(), ranges::distance(input), basic_borrowed_range{output}.begin());
STATIC_ASSERT(same_as<decltype(result),
copy_n_result<iterator_t<basic_borrowed_range<int const>>, iterator_t<basic_borrowed_range<int>>>>);
assert(result.in == wrapped_input.end());
assert(result.out == basic_borrowed_range{output}.end());
assert(ranges::equal(output, input));
}
using namespace std;

int main() {
STATIC_ASSERT((smoke_test(), true));
smoke_test();
}
// Validate that copy_n_result aliases in_out_result
STATIC_ASSERT(same_as<ranges::copy_n_result<int, double>, ranges::in_out_result<int, double>>);

struct instantiator {
template <class In, class Out>
static void call(In in = {}, std::iter_difference_t<In> const count = 42, Out out = {}) {
(void) ranges::copy_n(std::move(in), count, std::move(out));
static constexpr int input[3] = {13, 42, 1729};

template <ranges::input_range Read, indirectly_writable<ranges::range_reference_t<Read>> Write>
static constexpr void call() {
using ranges::copy_n, ranges::copy_n_result, ranges::iterator_t;
int output[3] = {-1, -1, -1};
Read wrapped_input{input};

auto result = copy_n(wrapped_input.begin(), 3, Write{output});
STATIC_ASSERT(same_as<decltype(result), copy_n_result<iterator_t<Read>, Write>>);
assert(result.in == wrapped_input.end());
assert(result.out.peek() == output + 3);
assert(ranges::equal(output, input));
}
};

template void test_read_write<instantiator, const int, int>();
int main() {
STATIC_ASSERT((test_in_write<instantiator, const int, int>(), true));
test_in_write<instantiator, const int, int>();
}