[libc++] implement move_iterator<T*> should be a random access iterator \n Differntial Revision- https://reviews.llvm.org/D135248
This commit is contained in:
@@ -260,6 +260,8 @@ Status
|
||||
------------------------------------------------- -----------------
|
||||
``__cpp_lib_math_constants`` ``201907L``
|
||||
------------------------------------------------- -----------------
|
||||
``__cpp_lib_move_iterator_concept`` ``202207L``
|
||||
------------------------------------------------- -----------------
|
||||
``__cpp_lib_polymorphic_allocator`` ``201902L``
|
||||
------------------------------------------------- -----------------
|
||||
``__cpp_lib_ranges`` ``202106L``
|
||||
|
||||
@@ -37,7 +37,7 @@ What's New in Libc++ 17.0.0?
|
||||
|
||||
Implemented Papers
|
||||
------------------
|
||||
|
||||
- P2520R0 - ``move_iterator<T*>`` should be a random access iterator
|
||||
- P1328R1 - ``constexpr type_info::operator==()``
|
||||
|
||||
Improvements and New Features
|
||||
|
||||
@@ -84,7 +84,7 @@
|
||||
"`P2508R1 <https://wg21.link/P2508R1>`__","LWG","Exposing ``std::basic-format-string``","July 2022","|Complete|","15.0"
|
||||
"`P2513R4 <https://wg21.link/P2513R4>`__","LWG","``char8_t`` Compatibility and Portability Fixes","July 2022","",""
|
||||
"`P2517R1 <https://wg21.link/P2517R1>`__","LWG","Add a conditional ``noexcept`` specification to ``std::apply``","July 2022","",""
|
||||
"`P2520R0 <https://wg21.link/P2520R0>`__","LWG","``move_iterator`` should be a random access iterator","July 2022","","","|ranges|"
|
||||
"`P2520R0 <https://wg21.link/P2520R0>`__","LWG","``move_iterator`` should be a random access iterator","July 2022","|Complete|","17.0","|ranges|"
|
||||
"`P2540R1 <https://wg21.link/P2540R1>`__","LWG","Empty Product for certain Views","July 2022","","","|ranges|"
|
||||
"`P2549R1 <https://wg21.link/P2549R1>`__","LWG","``std::unexpected`` should have ``error()`` as member accessor","July 2022","|Complete|","16.0"
|
||||
"`P2553R1 <https://wg21.link/P2553R1>`__","LWG","Make ``mdspan`` ``size_type`` controllable","July 2022","",""
|
||||
|
||||
|
@@ -67,10 +67,25 @@ class _LIBCPP_TEMPLATE_VIS move_iterator
|
||||
: public __move_iter_category_base<_Iter>
|
||||
#endif
|
||||
{
|
||||
#if _LIBCPP_STD_VER >= 20
|
||||
private:
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
static constexpr auto __get_iter_concept() {
|
||||
if constexpr (random_access_iterator<_Iter>) {
|
||||
return random_access_iterator_tag{};
|
||||
} else if constexpr (bidirectional_iterator<_Iter>) {
|
||||
return bidirectional_iterator_tag{};
|
||||
} else if constexpr (forward_iterator<_Iter>) {
|
||||
return forward_iterator_tag{};
|
||||
} else {
|
||||
return input_iterator_tag{};
|
||||
}
|
||||
}
|
||||
#endif // _LIBCPP_STD_VER >= 20
|
||||
public:
|
||||
#if _LIBCPP_STD_VER >= 20
|
||||
using iterator_type = _Iter;
|
||||
using iterator_concept = input_iterator_tag;
|
||||
using iterator_concept = decltype(__get_iter_concept());
|
||||
// iterator_category is inherited and not always present
|
||||
using value_type = iter_value_t<_Iter>;
|
||||
using difference_type = iter_difference_t<_Iter>;
|
||||
|
||||
@@ -387,7 +387,7 @@ template <class Iterator>
|
||||
class move_iterator {
|
||||
public:
|
||||
using iterator_type = Iterator;
|
||||
using iterator_concept = input_iterator_tag; // From C++20
|
||||
using iterator_concept = see below; // From C++20
|
||||
using iterator_category = see below; // not always present starting from C++20
|
||||
using value_type = iter_value_t<Iterator>; // Until C++20, iterator_traits<Iterator>::value_type
|
||||
using difference_type = iter_difference_t<Iterator>; // Until C++20, iterator_traits<Iterator>::difference_type;
|
||||
|
||||
@@ -122,6 +122,7 @@ __cpp_lib_map_try_emplace 201411L <map>
|
||||
__cpp_lib_math_constants 201907L <numbers>
|
||||
__cpp_lib_math_special_functions 201603L <cmath>
|
||||
__cpp_lib_memory_resource 201603L <memory_resource>
|
||||
__cpp_lib_move_iterator_concept 202207L <iterator>
|
||||
__cpp_lib_move_only_function 202110L <functional>
|
||||
__cpp_lib_node_extract 201606L <map> <set> <unordered_map>
|
||||
<unordered_set>
|
||||
@@ -356,6 +357,7 @@ __cpp_lib_void_t 201411L <type_traits>
|
||||
# endif
|
||||
# define __cpp_lib_list_remove_return_type 201806L
|
||||
# define __cpp_lib_math_constants 201907L
|
||||
# define __cpp_lib_move_iterator_concept 202207L
|
||||
# define __cpp_lib_polymorphic_allocator 201902L
|
||||
# define __cpp_lib_ranges 202106L
|
||||
# define __cpp_lib_remove_cvref 201711L
|
||||
|
||||
@@ -56,8 +56,8 @@ void test()
|
||||
|
||||
static_assert( std::default_initializable<iterator>);
|
||||
static_assert( std::copyable<iterator>);
|
||||
static_assert( std::input_iterator<iterator>);
|
||||
static_assert(!std::forward_iterator<iterator>);
|
||||
static_assert( std::forward_iterator<iterator>);
|
||||
static_assert(!std::bidirectional_iterator<iterator>);
|
||||
static_assert( std::sentinel_for<iterator, iterator>);
|
||||
static_assert(!std::sized_sentinel_for<iterator, iterator>);
|
||||
static_assert(!std::indirectly_movable<int*, iterator>);
|
||||
@@ -73,8 +73,8 @@ void test()
|
||||
|
||||
static_assert( std::default_initializable<iterator>);
|
||||
static_assert( std::copyable<iterator>);
|
||||
static_assert( std::input_iterator<iterator>);
|
||||
static_assert(!std::forward_iterator<iterator>);
|
||||
static_assert( std::bidirectional_iterator<iterator>);
|
||||
static_assert(!std::random_access_iterator<iterator>);
|
||||
static_assert( std::sentinel_for<iterator, iterator>);
|
||||
static_assert(!std::sized_sentinel_for<iterator, iterator>);
|
||||
static_assert(!std::indirectly_movable<int*, iterator>);
|
||||
@@ -90,8 +90,8 @@ void test()
|
||||
|
||||
static_assert( std::default_initializable<iterator>);
|
||||
static_assert( std::copyable<iterator>);
|
||||
static_assert( std::input_iterator<iterator>);
|
||||
static_assert(!std::forward_iterator<iterator>);
|
||||
static_assert( std::random_access_iterator<iterator>);
|
||||
static_assert(!std::contiguous_iterator<iterator>);
|
||||
static_assert( std::sentinel_for<iterator, iterator>);
|
||||
static_assert( std::sized_sentinel_for<iterator, iterator>);
|
||||
static_assert(!std::indirectly_movable<int*, iterator>);
|
||||
@@ -107,8 +107,8 @@ void test()
|
||||
|
||||
static_assert( std::default_initializable<iterator>);
|
||||
static_assert( std::copyable<iterator>);
|
||||
static_assert( std::input_iterator<iterator>);
|
||||
static_assert(!std::forward_iterator<iterator>);
|
||||
static_assert( std::random_access_iterator<iterator>);
|
||||
static_assert(!std::contiguous_iterator<iterator>);
|
||||
static_assert( std::sentinel_for<iterator, iterator>);
|
||||
static_assert( std::sized_sentinel_for<iterator, iterator>);
|
||||
static_assert(!std::indirectly_movable<int*, iterator>);
|
||||
@@ -124,8 +124,8 @@ void test()
|
||||
|
||||
static_assert( std::default_initializable<iterator>);
|
||||
static_assert( std::copyable<iterator>);
|
||||
static_assert( std::input_iterator<iterator>);
|
||||
static_assert(!std::forward_iterator<iterator>);
|
||||
static_assert( std::random_access_iterator<iterator>);
|
||||
static_assert(!std::contiguous_iterator<iterator>);
|
||||
static_assert( std::sentinel_for<iterator, iterator>);
|
||||
static_assert( std::sized_sentinel_for<iterator, iterator>);
|
||||
static_assert(!std::indirectly_movable<int*, iterator>);
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
// class move_iterator {
|
||||
// public:
|
||||
// using iterator_type = Iterator;
|
||||
// using iterator_concept = input_iterator_tag; // From C++20
|
||||
// using iterator_concept = see below; // From C++20
|
||||
// using iterator_category = see below; // not always present starting from C++20
|
||||
// using value_type = iter_value_t<Iterator>; // Until C++20, iterator_traits<Iterator>::value_type
|
||||
// using difference_type = iter_difference_t<Iterator>; // Until C++20, iterator_traits<Iterator>::difference_type;
|
||||
@@ -99,7 +99,8 @@ void test() {
|
||||
#endif
|
||||
|
||||
#if TEST_STD_VER > 17
|
||||
static_assert(std::is_same_v<typename R::iterator_concept, std::input_iterator_tag>);
|
||||
static_assert(std::is_same_v<typename R::iterator_concept, std::conditional_t<std::is_same_v<typename R::iterator_concept,
|
||||
std::contiguous_iterator_tag>, std::random_access_iterator_tag, typename R::iterator_concept>>);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -142,11 +143,11 @@ int main(int, char**) {
|
||||
|
||||
#if TEST_STD_VER > 17
|
||||
test<contiguous_iterator<char*>>();
|
||||
static_assert(std::is_same_v<typename std::move_iterator<forward_iterator<char*>>::iterator_concept, std::input_iterator_tag>);
|
||||
static_assert(std::is_same_v<typename std::move_iterator<bidirectional_iterator<char*>>::iterator_concept, std::input_iterator_tag>);
|
||||
static_assert(std::is_same_v<typename std::move_iterator<random_access_iterator<char*>>::iterator_concept, std::input_iterator_tag>);
|
||||
static_assert(std::is_same_v<typename std::move_iterator<contiguous_iterator<char*>>::iterator_concept, std::input_iterator_tag>);
|
||||
static_assert(std::is_same_v<typename std::move_iterator<char*>::iterator_concept, std::input_iterator_tag>);
|
||||
static_assert(std::is_same_v<typename std::move_iterator<forward_iterator<char*>>::iterator_concept, std::forward_iterator_tag>);
|
||||
static_assert(std::is_same_v<typename std::move_iterator<bidirectional_iterator<char*>>::iterator_concept, std::bidirectional_iterator_tag>);
|
||||
static_assert(std::is_same_v<typename std::move_iterator<random_access_iterator<char*>>::iterator_concept, std::random_access_iterator_tag>);
|
||||
static_assert(std::is_same_v<typename std::move_iterator<contiguous_iterator<char*>>::iterator_concept, std::random_access_iterator_tag>);
|
||||
static_assert(std::is_same_v<typename std::move_iterator<char*>::iterator_concept, std::random_access_iterator_tag>);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
201811L [C++20]
|
||||
__cpp_lib_constexpr_iterator 201811L [C++20]
|
||||
__cpp_lib_make_reverse_iterator 201402L [C++14]
|
||||
__cpp_lib_move_iterator_concept 202207L [C++20]
|
||||
__cpp_lib_nonmember_container_access 201411L [C++17]
|
||||
__cpp_lib_null_iterators 201304L [C++14]
|
||||
__cpp_lib_ranges 202106L [C++20]
|
||||
@@ -43,6 +44,10 @@
|
||||
# error "__cpp_lib_make_reverse_iterator should not be defined before c++14"
|
||||
# endif
|
||||
|
||||
# ifdef __cpp_lib_move_iterator_concept
|
||||
# error "__cpp_lib_move_iterator_concept should not be defined before c++20"
|
||||
# endif
|
||||
|
||||
# ifdef __cpp_lib_nonmember_container_access
|
||||
# error "__cpp_lib_nonmember_container_access should not be defined before c++17"
|
||||
# endif
|
||||
@@ -76,6 +81,10 @@
|
||||
# error "__cpp_lib_make_reverse_iterator should have the value 201402L in c++14"
|
||||
# endif
|
||||
|
||||
# ifdef __cpp_lib_move_iterator_concept
|
||||
# error "__cpp_lib_move_iterator_concept should not be defined before c++20"
|
||||
# endif
|
||||
|
||||
# ifdef __cpp_lib_nonmember_container_access
|
||||
# error "__cpp_lib_nonmember_container_access should not be defined before c++17"
|
||||
# endif
|
||||
@@ -115,6 +124,10 @@
|
||||
# error "__cpp_lib_make_reverse_iterator should have the value 201402L in c++17"
|
||||
# endif
|
||||
|
||||
# ifdef __cpp_lib_move_iterator_concept
|
||||
# error "__cpp_lib_move_iterator_concept should not be defined before c++20"
|
||||
# endif
|
||||
|
||||
# ifndef __cpp_lib_nonmember_container_access
|
||||
# error "__cpp_lib_nonmember_container_access should be defined in c++17"
|
||||
# endif
|
||||
@@ -160,6 +173,13 @@
|
||||
# error "__cpp_lib_make_reverse_iterator should have the value 201402L in c++20"
|
||||
# endif
|
||||
|
||||
# ifndef __cpp_lib_move_iterator_concept
|
||||
# error "__cpp_lib_move_iterator_concept should be defined in c++20"
|
||||
# endif
|
||||
# if __cpp_lib_move_iterator_concept != 202207L
|
||||
# error "__cpp_lib_move_iterator_concept should have the value 202207L in c++20"
|
||||
# endif
|
||||
|
||||
# ifndef __cpp_lib_nonmember_container_access
|
||||
# error "__cpp_lib_nonmember_container_access should be defined in c++20"
|
||||
# endif
|
||||
@@ -211,6 +231,13 @@
|
||||
# error "__cpp_lib_make_reverse_iterator should have the value 201402L in c++2b"
|
||||
# endif
|
||||
|
||||
# ifndef __cpp_lib_move_iterator_concept
|
||||
# error "__cpp_lib_move_iterator_concept should be defined in c++2b"
|
||||
# endif
|
||||
# if __cpp_lib_move_iterator_concept != 202207L
|
||||
# error "__cpp_lib_move_iterator_concept should have the value 202207L in c++2b"
|
||||
# endif
|
||||
|
||||
# ifndef __cpp_lib_nonmember_container_access
|
||||
# error "__cpp_lib_nonmember_container_access should be defined in c++2b"
|
||||
# endif
|
||||
|
||||
@@ -116,6 +116,7 @@
|
||||
__cpp_lib_math_constants 201907L [C++20]
|
||||
__cpp_lib_math_special_functions 201603L [C++17]
|
||||
__cpp_lib_memory_resource 201603L [C++17]
|
||||
__cpp_lib_move_iterator_concept 202207L [C++20]
|
||||
__cpp_lib_move_only_function 202110L [C++2b]
|
||||
__cpp_lib_node_extract 201606L [C++17]
|
||||
__cpp_lib_nonmember_container_access 201411L [C++17]
|
||||
@@ -578,6 +579,10 @@
|
||||
# error "__cpp_lib_memory_resource should not be defined before c++17"
|
||||
# endif
|
||||
|
||||
# ifdef __cpp_lib_move_iterator_concept
|
||||
# error "__cpp_lib_move_iterator_concept should not be defined before c++20"
|
||||
# endif
|
||||
|
||||
# ifdef __cpp_lib_move_only_function
|
||||
# error "__cpp_lib_move_only_function should not be defined before c++2b"
|
||||
# endif
|
||||
@@ -1250,6 +1255,10 @@
|
||||
# error "__cpp_lib_memory_resource should not be defined before c++17"
|
||||
# endif
|
||||
|
||||
# ifdef __cpp_lib_move_iterator_concept
|
||||
# error "__cpp_lib_move_iterator_concept should not be defined before c++20"
|
||||
# endif
|
||||
|
||||
# ifdef __cpp_lib_move_only_function
|
||||
# error "__cpp_lib_move_only_function should not be defined before c++2b"
|
||||
# endif
|
||||
@@ -2072,6 +2081,10 @@
|
||||
# error "__cpp_lib_memory_resource should have the value 201603L in c++17"
|
||||
# endif
|
||||
|
||||
# ifdef __cpp_lib_move_iterator_concept
|
||||
# error "__cpp_lib_move_iterator_concept should not be defined before c++20"
|
||||
# endif
|
||||
|
||||
# ifdef __cpp_lib_move_only_function
|
||||
# error "__cpp_lib_move_only_function should not be defined before c++2b"
|
||||
# endif
|
||||
@@ -3176,6 +3189,13 @@
|
||||
# error "__cpp_lib_memory_resource should have the value 201603L in c++20"
|
||||
# endif
|
||||
|
||||
# ifndef __cpp_lib_move_iterator_concept
|
||||
# error "__cpp_lib_move_iterator_concept should be defined in c++20"
|
||||
# endif
|
||||
# if __cpp_lib_move_iterator_concept != 202207L
|
||||
# error "__cpp_lib_move_iterator_concept should have the value 202207L in c++20"
|
||||
# endif
|
||||
|
||||
# ifdef __cpp_lib_move_only_function
|
||||
# error "__cpp_lib_move_only_function should not be defined before c++2b"
|
||||
# endif
|
||||
@@ -4415,6 +4435,13 @@
|
||||
# error "__cpp_lib_memory_resource should have the value 201603L in c++2b"
|
||||
# endif
|
||||
|
||||
# ifndef __cpp_lib_move_iterator_concept
|
||||
# error "__cpp_lib_move_iterator_concept should be defined in c++2b"
|
||||
# endif
|
||||
# if __cpp_lib_move_iterator_concept != 202207L
|
||||
# error "__cpp_lib_move_iterator_concept should have the value 202207L in c++2b"
|
||||
# endif
|
||||
|
||||
# if !defined(_LIBCPP_VERSION)
|
||||
# ifndef __cpp_lib_move_only_function
|
||||
# error "__cpp_lib_move_only_function should be defined in c++2b"
|
||||
|
||||
@@ -488,6 +488,10 @@ feature_test_macros = [ add_version_header(x) for x in [
|
||||
"values": { "c++17": 201603 },
|
||||
"headers": ["memory_resource"],
|
||||
}, {
|
||||
"name": "__cpp_lib_move_iterator_concept",
|
||||
"values": { "c++20": 202207 },
|
||||
"headers": ["iterator"],
|
||||
}, {
|
||||
"name": "__cpp_lib_move_only_function",
|
||||
"values": { "c++2b": 202110 },
|
||||
"headers": ["functional"],
|
||||
|
||||
Reference in New Issue
Block a user