Skip to content

Commit eebf7ad

Browse files
committed
[P0843R2] Prepatory work
1 parent 2914b43 commit eebf7ad

File tree

7 files changed

+504
-351
lines changed

7 files changed

+504
-351
lines changed

stl/inc/algorithm

+24-32
Original file line numberDiff line numberDiff line change
@@ -1542,7 +1542,7 @@ namespace ranges {
15421542
// clang-format off
15431543
template <input_iterator _It, sentinel_for<_It> _Se, weakly_incrementable _Out>
15441544
requires indirectly_copyable<_It, _Out>
1545-
_NODISCARD constexpr copy_result<_It, _Out> _Copy_unchecked(_It _First, const _Se _Last, _Out _Result) {
1545+
constexpr copy_result<_It, _Out> _Copy_unchecked(_It _First, const _Se _Last, _Out _Result) {
15461546
for (; _First != _Last; ++_First, (void) ++_Result) {
15471547
*_Result = *_First;
15481548
}
@@ -1734,6 +1734,17 @@ namespace ranges {
17341734
using move_result = in_out_result<_In, _Out>;
17351735

17361736
// VARIABLE ranges::move
1737+
template <input_iterator _It, sentinel_for<_It> _Se, weakly_incrementable _Out>
1738+
constexpr move_result<_It, _Out> _Move_unchecked(_It _First, const _Se _Last, _Out _Result) {
1739+
_STL_INTERNAL_STATIC_ASSERT(indirectly_movable<_It, _Out>);
1740+
1741+
for (; _First != _Last; ++_First, (void) ++_Result) {
1742+
*_Result = _RANGES iter_move(_First);
1743+
}
1744+
1745+
return {_STD move(_First), _STD move(_Result)};
1746+
}
1747+
17371748
class _Move_fn : private _Not_quite_object {
17381749
public:
17391750
using _Not_quite_object::_Not_quite_object;
@@ -1760,21 +1771,6 @@ namespace ranges {
17601771
return {_STD move(_First), _STD move(_UResult.out)};
17611772
}
17621773
// clang-format on
1763-
1764-
private:
1765-
template <class _It, class _Se, class _Out>
1766-
_NODISCARD static constexpr move_result<_It, _Out> _Move_unchecked(_It _First, const _Se _Last, _Out _Result) {
1767-
_STL_INTERNAL_STATIC_ASSERT(input_iterator<_It>);
1768-
_STL_INTERNAL_STATIC_ASSERT(sentinel_for<_Se, _It>);
1769-
_STL_INTERNAL_STATIC_ASSERT(weakly_incrementable<_Out>);
1770-
_STL_INTERNAL_STATIC_ASSERT(indirectly_movable<_It, _Out>);
1771-
1772-
for (; _First != _Last; ++_First, (void) ++_Result) {
1773-
*_Result = _RANGES iter_move(_First);
1774-
}
1775-
1776-
return {_STD move(_First), _STD move(_Result)};
1777-
}
17781774
};
17791775

17801776
inline constexpr _Move_fn move{_Not_quite_object::_Construct_tag{}};
@@ -3281,6 +3277,18 @@ namespace ranges {
32813277
using swap_ranges_result = in_in_result<_In1, _In2>;
32823278

32833279
// VARIABLE ranges::swap_ranges
3280+
template <input_iterator _It1, sentinel_for<_It1> _Se1, input_iterator _It2, sentinel_for<_It2> _Se2>
3281+
_NODISCARD constexpr swap_ranges_result<_It1, _It2> _Swap_ranges_unchecked(
3282+
_It1 _First1, const _Se1 _Last1, _It2 _First2, const _Se2 _Last2) {
3283+
_STL_INTERNAL_STATIC_ASSERT(indirectly_swappable<_It1, _It2>);
3284+
3285+
for (; _First1 != _Last1 && _First2 != _Last2; ++_First1, (void) ++_First2) {
3286+
_RANGES iter_swap(_First1, _First2);
3287+
}
3288+
3289+
return {_STD move(_First1), _STD move(_First2)};
3290+
}
3291+
32843292
class _Swap_ranges_fn : private _Not_quite_object {
32853293
public:
32863294
using _Not_quite_object::_Not_quite_object;
@@ -3317,22 +3325,6 @@ namespace ranges {
33173325
return {_STD move(_First1), _STD move(_First2)};
33183326
}
33193327
// clang-format on
3320-
private:
3321-
template <class _It1, class _Se1, class _It2, class _Se2>
3322-
_NODISCARD static constexpr swap_ranges_result<_It1, _It2> _Swap_ranges_unchecked(
3323-
_It1 _First1, const _Se1 _Last1, _It2 _First2, const _Se2 _Last2) {
3324-
_STL_INTERNAL_STATIC_ASSERT(input_iterator<_It1>);
3325-
_STL_INTERNAL_STATIC_ASSERT(sentinel_for<_Se1, _It1>);
3326-
_STL_INTERNAL_STATIC_ASSERT(input_iterator<_It2>);
3327-
_STL_INTERNAL_STATIC_ASSERT(sentinel_for<_Se2, _It2>);
3328-
_STL_INTERNAL_STATIC_ASSERT(indirectly_swappable<_It1, _It2>);
3329-
3330-
for (; _First1 != _Last1 && _First2 != _Last2; ++_First1, (void) ++_First2) {
3331-
_RANGES iter_swap(_First1, _First2);
3332-
}
3333-
3334-
return {_STD move(_First1), _STD move(_First2)};
3335-
}
33363328
};
33373329

33383330
inline constexpr _Swap_ranges_fn swap_ranges{_Not_quite_object::_Construct_tag{}};

0 commit comments

Comments
 (0)