|
24 | 24 | #include <__iterator/readable_traits.h>
|
25 | 25 | #include <__type_traits/common_reference.h>
|
26 | 26 | #include <__type_traits/conditional.h>
|
| 27 | +#include <__type_traits/detected_or.h> |
27 | 28 | #include <__type_traits/disjunction.h>
|
28 | 29 | #include <__type_traits/enable_if.h>
|
29 | 30 | #include <__type_traits/integral_constant.h>
|
|
32 | 33 | #include <__type_traits/is_primary_template.h>
|
33 | 34 | #include <__type_traits/is_reference.h>
|
34 | 35 | #include <__type_traits/is_valid_expansion.h>
|
| 36 | +#include <__type_traits/nat.h> |
35 | 37 | #include <__type_traits/remove_const.h>
|
36 | 38 | #include <__type_traits/remove_cv.h>
|
37 | 39 | #include <__type_traits/remove_cvref.h>
|
@@ -128,30 +130,6 @@ struct __has_iterator_typedefs {
|
128 | 130 | static const bool value = decltype(__test<_Tp>(nullptr, nullptr, nullptr, nullptr, nullptr))::value;
|
129 | 131 | };
|
130 | 132 |
|
131 |
| -template <class _Tp> |
132 |
| -struct __has_iterator_category { |
133 |
| -private: |
134 |
| - template <class _Up> |
135 |
| - static false_type __test(...); |
136 |
| - template <class _Up> |
137 |
| - static true_type __test(typename _Up::iterator_category* = nullptr); |
138 |
| - |
139 |
| -public: |
140 |
| - static const bool value = decltype(__test<_Tp>(nullptr))::value; |
141 |
| -}; |
142 |
| - |
143 |
| -template <class _Tp> |
144 |
| -struct __has_iterator_concept { |
145 |
| -private: |
146 |
| - template <class _Up> |
147 |
| - static false_type __test(...); |
148 |
| - template <class _Up> |
149 |
| - static true_type __test(typename _Up::iterator_concept* = nullptr); |
150 |
| - |
151 |
| -public: |
152 |
| - static const bool value = decltype(__test<_Tp>(nullptr))::value; |
153 |
| -}; |
154 |
| - |
155 | 133 | #if _LIBCPP_STD_VER >= 20
|
156 | 134 |
|
157 | 135 | // The `cpp17-*-iterator` exposition-only concepts have very similar names to the `Cpp17*Iterator` named requirements
|
@@ -419,18 +397,19 @@ struct _LIBCPP_TEMPLATE_VIS iterator_traits<_Tp*> {
|
419 | 397 | #endif
|
420 | 398 | };
|
421 | 399 |
|
422 |
| -template <class _Tp, class _Up, bool = __has_iterator_category<iterator_traits<_Tp> >::value> |
423 |
| -struct __has_iterator_category_convertible_to : is_convertible<typename iterator_traits<_Tp>::iterator_category, _Up> { |
424 |
| -}; |
| 400 | +template <class _Tp> |
| 401 | +using __iterator_category _LIBCPP_NODEBUG = typename _Tp::iterator_category; |
425 | 402 |
|
426 |
| -template <class _Tp, class _Up> |
427 |
| -struct __has_iterator_category_convertible_to<_Tp, _Up, false> : false_type {}; |
| 403 | +template <class _Tp> |
| 404 | +using __iterator_concept _LIBCPP_NODEBUG = typename _Tp::iterator_concept; |
428 | 405 |
|
429 |
| -template <class _Tp, class _Up, bool = __has_iterator_concept<_Tp>::value> |
430 |
| -struct __has_iterator_concept_convertible_to : is_convertible<typename _Tp::iterator_concept, _Up> {}; |
| 406 | +template <class _Tp, class _Up> |
| 407 | +using __has_iterator_category_convertible_to _LIBCPP_NODEBUG = |
| 408 | + is_convertible<__detected_or_t<__nat, __iterator_category, iterator_traits<_Tp> >, _Up>; |
431 | 409 |
|
432 | 410 | template <class _Tp, class _Up>
|
433 |
| -struct __has_iterator_concept_convertible_to<_Tp, _Up, false> : false_type {}; |
| 411 | +using __has_iterator_concept_convertible_to _LIBCPP_NODEBUG = |
| 412 | + is_convertible<__detected_or_t<__nat, __iterator_concept, _Tp>, _Up>; |
434 | 413 |
|
435 | 414 | template <class _Tp>
|
436 | 415 | using __has_input_iterator_category _LIBCPP_NODEBUG = __has_iterator_category_convertible_to<_Tp, input_iterator_tag>;
|
|
0 commit comments