[libcxx-commits] [PATCH] D136356: [libc++] implement move_iterator<T*> should be a random access iterator
Shivam Rajput via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Oct 21 13:18:42 PDT 2022
phyBrackets edited the summary of this revision.
phyBrackets updated this revision to Diff 469737.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D136356/new/
https://reviews.llvm.org/D136356
Files:
libcxx/include/__iterator/move_iterator.h
libcxx/include/version
Index: libcxx/include/version
===================================================================
--- libcxx/include/version
+++ libcxx/include/version
@@ -116,6 +116,7 @@
__cpp_lib_logical_traits 201510L <type_traits>
__cpp_lib_make_from_tuple 201606L <tuple>
__cpp_lib_make_reverse_iterator 201402L <iterator>
+__cpp_lib_move_iterator_concept 202207L <iterator>
__cpp_lib_make_unique 201304L <memory>
__cpp_lib_map_try_emplace 201411L <map>
__cpp_lib_math_constants 201907L <numbers>
@@ -295,6 +296,7 @@
# undef __cpp_lib_array_constexpr
# define __cpp_lib_array_constexpr 201811L
# define __cpp_lib_assume_aligned 201811L
+#define __cpp_lib_move_iterator_concept 202207L
# define __cpp_lib_atomic_flag_test 201907L
// # define __cpp_lib_atomic_float 201711L
# define __cpp_lib_atomic_lock_free_type_aliases 201907L
Index: libcxx/include/__iterator/move_iterator.h
===================================================================
--- libcxx/include/__iterator/move_iterator.h
+++ libcxx/include/__iterator/move_iterator.h
@@ -59,10 +59,27 @@
: public __move_iter_category_base<_Iter>
#endif
{
+ private:
+
+ static constexpr auto _Get_Iterator_Tag() {
+ if constexpr (__is_cpp17_random_access_iterator<_Iter>::value) {
+ return random_access_iterator_tag{};
+ } else if constexpr (__is_cpp17_forward_iterator<_Iter>::value) {
+ return forward_iterator_tag{};
+ } else if constexpr (__is_cpp17_bidirectional_iterator<_Iter>::value) {
+ return bidirectional_iterator_tag{};
+ } else {
+ return input_iterator_tag{};
+ }
+ }
+ template<class _It2> friend class move_iterator;
+
+ _Iter __current_;
+
public:
#if _LIBCPP_STD_VER > 17
using iterator_type = _Iter;
- using iterator_concept = input_iterator_tag;
+ using iterator_concept = decltype(_Get_Iterator_Tag());
// iterator_category is inherited and not always present
using value_type = iter_value_t<_Iter>;
using difference_type = iter_difference_t<_Iter>;
@@ -216,11 +233,6 @@
return ranges::iter_swap(__x.__current_, __y.__current_);
}
#endif // _LIBCPP_STD_VER > 17
-
-private:
- template<class _It2> friend class move_iterator;
-
- _Iter __current_;
};
_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(move_iterator);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136356.469737.patch
Type: text/x-patch
Size: 2621 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20221021/0985abc7/attachment.bin>
More information about the libcxx-commits
mailing list