Skip to content

Commit 9db7502

Browse files
authored
[libc++] Move __has_iterator_typedefs to the up-to-C++17 implementation of iterator_traits (#144265)
`__has_iterator_typedefs` is only used in the up-to-C++17 implementation of `type_traits`. To make that clearer the struct is moved into that code block.
1 parent 1d6f102 commit 9db7502

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

libcxx/include/__iterator/iterator_traits.h

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -71,23 +71,6 @@ struct random_access_iterator_tag : public bidirectional_iterator_tag {};
7171
struct contiguous_iterator_tag : public random_access_iterator_tag {};
7272
#endif
7373

74-
template <class _Tp>
75-
struct __has_iterator_typedefs {
76-
private:
77-
template <class _Up>
78-
static false_type __test(...);
79-
template <class _Up>
80-
static true_type
81-
__test(__void_t<typename _Up::iterator_category>* = nullptr,
82-
__void_t<typename _Up::difference_type>* = nullptr,
83-
__void_t<typename _Up::value_type>* = nullptr,
84-
__void_t<typename _Up::reference>* = nullptr,
85-
__void_t<typename _Up::pointer>* = nullptr);
86-
87-
public:
88-
static const bool value = decltype(__test<_Tp>(nullptr, nullptr, nullptr, nullptr, nullptr))::value;
89-
};
90-
9174
#if _LIBCPP_STD_VER >= 20
9275

9376
// The `cpp17-*-iterator` exposition-only concepts have very similar names to the `Cpp17*Iterator` named requirements
@@ -322,6 +305,23 @@ struct __iterator_traits<_Iter, true>
322305
is_convertible<typename _Iter::iterator_category, input_iterator_tag>::value ||
323306
is_convertible<typename _Iter::iterator_category, output_iterator_tag>::value > {};
324307

308+
template <class _Tp>
309+
struct __has_iterator_typedefs {
310+
private:
311+
template <class _Up>
312+
static false_type __test(...);
313+
template <class _Up>
314+
static true_type
315+
__test(__void_t<typename _Up::iterator_category>* = nullptr,
316+
__void_t<typename _Up::difference_type>* = nullptr,
317+
__void_t<typename _Up::value_type>* = nullptr,
318+
__void_t<typename _Up::reference>* = nullptr,
319+
__void_t<typename _Up::pointer>* = nullptr);
320+
321+
public:
322+
static const bool value = decltype(__test<_Tp>(nullptr, nullptr, nullptr, nullptr, nullptr))::value;
323+
};
324+
325325
// iterator_traits<Iterator> will only have the nested types if Iterator::iterator_category
326326
// exists. Else iterator_traits<Iterator> will be an empty class. This is a
327327
// conforming extension which allows some programs to compile and behave as

0 commit comments

Comments
 (0)