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
14 changes: 0 additions & 14 deletions stl/inc/algorithm
Original file line number Diff line number Diff line change
Expand Up @@ -215,20 +215,6 @@ namespace ranges {
}
}

// FUNCTION TEMPLATE _Rewrap_iterator
template <forward_range _Rng, class _It>
_NODISCARD constexpr iterator_t<_Rng> _Rewrap_iterator(_Rng&& _Range, _It&& _Val) {
_STL_INTERNAL_STATIC_ASSERT(is_same_v<remove_cvref_t<_It>, _Unwrapped_t<iterator_t<_Rng>>>);

if constexpr (is_same_v<remove_cvref_t<_It>, iterator_t<_Rng>>) {
return _STD forward<_It>(_Val);
} else {
auto _Result = _RANGES begin(_Range);
_Result._Seek_to(_STD forward<_It>(_Val));
return _Result;
}
}

// FUNCTION TEMPLATE _Get_final_iterator_unwrapped
template <forward_iterator _Wrapped, sentinel_for<_Wrapped> _Se>
_NODISCARD constexpr auto _Get_final_iterator_unwrapped(const _Unwrapped_t<_Wrapped>& _UFirst, _Se&& _Last) {
Expand Down
14 changes: 14 additions & 0 deletions stl/inc/xutility
Original file line number Diff line number Diff line change
Expand Up @@ -4766,6 +4766,20 @@ _NODISCARD bool equal(_ExPo&& _Exec, const _FwdIt1 _First1, const _FwdIt1 _Last1

#ifdef __cpp_lib_concepts
namespace ranges {
// FUNCTION TEMPLATE _Rewrap_iterator
template <forward_range _Rng, class _It>
_NODISCARD constexpr iterator_t<_Rng> _Rewrap_iterator(_Rng&& _Range, _It&& _Val) {
_STL_INTERNAL_STATIC_ASSERT(is_same_v<remove_cvref_t<_It>, _Unwrapped_t<iterator_t<_Rng>>>);

if constexpr (is_same_v<remove_cvref_t<_It>, iterator_t<_Rng>>) {
return _STD forward<_It>(_Val);
} else {
auto _Result = _RANGES begin(_Range);
_Result._Seek_to(_STD forward<_It>(_Val));
return _Result;
}
}

// CONCEPT _Convertible_from
template <class _To, class _From>
concept _Convertible_from = convertible_to<_From, _To>;
Expand Down
13 changes: 12 additions & 1 deletion tests/std/tests/P0896R4_ranges_alg_uninitialized_copy/test.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
// Copyright (c) Microsoft Corporation.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#include <memory>

// Regression test for GH-1830, in which ranges::uninitialized_copy used
// _Rewrap_iterator which was defined in <algorithm> (now in <xutility>).

void unused_function() {
const int src[] = {11, 22, 33, 44, 55};
int dst[5];

std::ranges::uninitialized_copy(src, dst);
}

#include <algorithm>
#include <cassert>
#include <concepts>
#include <cstdlib>
#include <memory>
#include <ranges>
#include <span>
#include <utility>
Expand Down