[libc++][ranges] LWG3618: Unnecessary iter_move
for transform_view::iterator
(#91809)
## Introduction This patch implements LWG3618: Unnecessary `iter_move` for `transform_view::iterator`. `transform_view`'s iterator currently specifies a customization point for `iter_move`. This customization point does the same thing that the default implementation would do, but its sole purpose is to ensure the appropriate conditional `noexcept` specification. ## Reference - [[range.transform.iterator]](https://eel.is/c++draft/range.transform.iterator) - [LWG3618](https://cplusplus.github.io/LWG/issue3618)
This commit is contained in:
parent
ec966f699d
commit
3d7622ea0b
@ -146,7 +146,7 @@
|
||||
"`3610 <https://wg21.link/LWG3610>`__","``iota_view::size`` sometimes rejects integer-class types","February 2022","","","|ranges|"
|
||||
"`3612 <https://wg21.link/LWG3612>`__","Inconsistent pointer alignment in ``std::format`` ","February 2022","|Complete|","14.0","|format|"
|
||||
"`3616 <https://wg21.link/LWG3616>`__","LWG 3498 seems to miss the non-member ``swap`` for ``basic_syncbuf`` ","February 2022","",""
|
||||
"`3618 <https://wg21.link/LWG3618>`__","Unnecessary ``iter_move`` for ``transform_view::iterator`` ","February 2022","","","|ranges|"
|
||||
"`3618 <https://wg21.link/LWG3618>`__","Unnecessary ``iter_move`` for ``transform_view::iterator`` ","February 2022","|Complete|","19.0","|ranges|"
|
||||
"`3619 <https://wg21.link/LWG3619>`__","Specification of ``vformat_to`` contains ill-formed ``formatted_size`` calls","February 2022","|Nothing to do|","","|format|"
|
||||
"`3621 <https://wg21.link/LWG3621>`__","Remove feature-test macro ``__cpp_lib_monadic_optional`` ","February 2022","|Complete|","15.0"
|
||||
"`3632 <https://wg21.link/LWG3632>`__","``unique_ptr`` ""Mandates: This constructor is not selected by class template argument deduction""","February 2022","|Nothing to do|",""
|
||||
|
Can't render this file because it has a wrong number of fields in line 2.
|
@ -326,13 +326,6 @@ public:
|
||||
{
|
||||
return __x.__current_ - __y.__current_;
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI friend constexpr decltype(auto) iter_move(const __iterator& __i) noexcept(noexcept(*__i)) {
|
||||
if constexpr (is_lvalue_reference_v<decltype(*__i)>)
|
||||
return std::move(*__i);
|
||||
else
|
||||
return *__i;
|
||||
}
|
||||
};
|
||||
|
||||
# if _LIBCPP_STD_VER >= 23
|
||||
|
@ -37,7 +37,7 @@ int main(int, char**) {
|
||||
using View = std::ranges::transform_view<MoveOnlyView, PlusOneNoexcept>;
|
||||
View transformView(MoveOnlyView{buff}, PlusOneNoexcept{});
|
||||
assert(*transformView.begin() == 1);
|
||||
LIBCPP_ASSERT_NOEXCEPT(*std::declval<std::ranges::iterator_t<View>>());
|
||||
ASSERT_NOEXCEPT(*std::declval<std::ranges::iterator_t<View>>());
|
||||
ASSERT_SAME_TYPE(int, decltype(*std::declval<View>().begin()));
|
||||
}
|
||||
{
|
||||
|
@ -1,49 +0,0 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// UNSUPPORTED: c++03, c++11, c++14, c++17
|
||||
|
||||
// friend constexpr decltype(auto) iter_move(const iterator& i)
|
||||
// noexcept(noexcept(invoke(i.parent_->fun_, *i.current_)))
|
||||
|
||||
#include <ranges>
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "../types.h"
|
||||
|
||||
constexpr bool test() {
|
||||
int buff[8] = {0, 1, 2, 3, 4, 5, 6, 7};
|
||||
|
||||
{
|
||||
std::ranges::transform_view transformView(MoveOnlyView{buff}, PlusOneMutable{});
|
||||
auto iter = transformView.begin();
|
||||
ASSERT_NOT_NOEXCEPT(std::ranges::iter_move(iter));
|
||||
|
||||
assert(std::ranges::iter_move(iter) == 1);
|
||||
assert(std::ranges::iter_move(iter + 2) == 3);
|
||||
|
||||
ASSERT_SAME_TYPE(int, decltype(std::ranges::iter_move(iter)));
|
||||
ASSERT_SAME_TYPE(int, decltype(std::ranges::iter_move(std::move(iter))));
|
||||
}
|
||||
|
||||
{
|
||||
LIBCPP_ASSERT_NOEXCEPT(std::ranges::iter_move(
|
||||
std::declval<std::ranges::iterator_t<std::ranges::transform_view<MoveOnlyView, PlusOneNoexcept>>&>()));
|
||||
ASSERT_NOT_NOEXCEPT(std::ranges::iter_move(
|
||||
std::declval<std::ranges::iterator_t<std::ranges::transform_view<MoveOnlyView, PlusOneMutable>>&>()));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**) {
|
||||
test();
|
||||
static_assert(test());
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user