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
2 changes: 1 addition & 1 deletion stl/inc/memory
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ namespace ranges {
_STL_INTERNAL_STATIC_ASSERT(_No_throw_sentinel_for<_OSe, _Out>);
_STL_INTERNAL_STATIC_ASSERT(constructible_from<iter_value_t<_Out>, iter_reference_t<_It>>);

if constexpr (is_same_v<_Se, _It> && _Ptr_copy_cat<_It, _Out>::_Really_trivial) {
if constexpr (is_same_v<_Se, _It> && is_same_v<_OSe, _Out> && _Ptr_copy_cat<_It, _Out>::_Really_trivial) {
return _Copy_memcpy_common(_IFirst, _ILast, _OFirst, _OLast);
} else {
_Uninitialized_backout _Backout{_STD move(_OFirst)};
Expand Down
2 changes: 1 addition & 1 deletion stl/inc/xmemory
Original file line number Diff line number Diff line change
Expand Up @@ -1582,7 +1582,7 @@ namespace ranges {
uninitialized_move_result<_It, _Out> _Uninitialized_move_unchecked(
_It _IFirst, const _Se _ILast, _Out _OFirst, const _OSe _OLast) {
// clang-format on
if constexpr (is_same_v<_Se, _It> && _Ptr_move_cat<_It, _Out>::_Really_trivial) {
if constexpr (is_same_v<_Se, _It> && is_same_v<_OSe, _Out> && _Ptr_move_cat<_It, _Out>::_Really_trivial) {
return _Copy_memcpy_common(_IFirst, _ILast, _OFirst, _OLast);
} else {
_Uninitialized_backout _Backout{_STD move(_OFirst)};
Expand Down
26 changes: 25 additions & 1 deletion tests/std/tests/P0896R4_ranges_alg_uninitialized_copy/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ struct memcpy_test {
static constexpr int expected_input_long[] = {13, 55, 12345, 42};

static void call() {
{ // Validate only range overload
{ // Validate matching ranges
int input[] = {13, 55, 12345};
int output[] = {-1, -1, -1};

Expand Down Expand Up @@ -235,6 +235,30 @@ struct memcpy_test {
assert(ranges::equal(input, expected_input_long));
assert(ranges::equal(output, expected_output));
}

{ // Validate non-common input range
int input[] = {13, 55, 12345};
int output[] = {-1, -1, -1};

const auto result =
ranges::uninitialized_copy(begin(input), unreachable_sentinel, begin(output), end(output));
assert(result.in == end(input));
assert(result.out == end(output));
assert(ranges::equal(input, expected_input));
assert(ranges::equal(output, expected_output));
}

{ // Validate non-common output range
int input[] = {13, 55, 12345};
int output[] = {-1, -1, -1};

const auto result =
ranges::uninitialized_copy(begin(input), end(input), begin(output), unreachable_sentinel);
assert(result.in == end(input));
assert(result.out == end(output));
assert(ranges::equal(input, expected_input));
assert(ranges::equal(output, expected_output));
}
}
};

Expand Down
30 changes: 28 additions & 2 deletions tests/std/tests/P0896R4_ranges_alg_uninitialized_move/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,13 @@ struct memcpy_test {
static constexpr int expected_input_long[] = {13, 55, 12345, 42};

static void call() {
{ // Validate range
{ // Validate matching ranges
int input[] = {13, 55, 12345};
int output[] = {-1, -1, -1};

ranges::uninitialized_move(input, output);
const auto result = ranges::uninitialized_move(input, output);
assert(result.in == end(input));
assert(result.out == end(output));
assert(ranges::equal(input, expected_input));
assert(ranges::equal(output, expected_output));
}
Expand All @@ -234,6 +236,30 @@ struct memcpy_test {
assert(ranges::equal(input, expected_input_long));
assert(ranges::equal(output, expected_output));
}

{ // Validate non-common input range
int input[] = {13, 55, 12345};
int output[] = {-1, -1, -1};

const auto result =
ranges::uninitialized_move(begin(input), unreachable_sentinel, begin(output), end(output));
assert(result.in == end(input));
assert(result.out == end(output));
assert(ranges::equal(input, expected_input));
assert(ranges::equal(output, expected_output));
}

{ // Validate non-common output range
int input[] = {13, 55, 12345};
int output[] = {-1, -1, -1};

const auto result =
ranges::uninitialized_move(begin(input), end(input), begin(output), unreachable_sentinel);
assert(result.in == end(input));
assert(result.out == end(output));
assert(ranges::equal(input, expected_input));
assert(ranges::equal(output, expected_output));
}
}
};

Expand Down