From d49e7367d9398498838549dc4733efe980c7c3e1 Mon Sep 17 00:00:00 2001 From: "A. Jiang" Date: Wed, 5 Nov 2025 11:08:10 +0800 Subject: [PATCH] [libc++] Guard uses of `is_transparent` and `iterator_concept` Before C++14/20, `is_transparent` and `iterator_concept` were not reserved at all respectively, and users might define them as macros. --- libcxx/include/__filesystem/path_iterator.h | 4 +++- libcxx/include/__functional/identity.h | 2 ++ libcxx/include/__iterator/iterator_traits.h | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/libcxx/include/__filesystem/path_iterator.h b/libcxx/include/__filesystem/path_iterator.h index 3fab2b7ff34d0..ec292f858d812 100644 --- a/libcxx/include/__filesystem/path_iterator.h +++ b/libcxx/include/__filesystem/path_iterator.h @@ -37,7 +37,9 @@ class _LIBCPP_EXPORTED_FROM_ABI path::iterator { public: typedef input_iterator_tag iterator_category; - typedef bidirectional_iterator_tag iterator_concept; +# if _LIBCPP_STD_VER >= 20 + using iterator_concept = bidirectional_iterator_tag; +# endif typedef path value_type; typedef ptrdiff_t difference_type; diff --git a/libcxx/include/__functional/identity.h b/libcxx/include/__functional/identity.h index 02dde2b4f323d..e2dd5e1fa8123 100644 --- a/libcxx/include/__functional/identity.h +++ b/libcxx/include/__functional/identity.h @@ -30,7 +30,9 @@ struct __identity { return std::forward<_Tp>(__t); } +#if _LIBCPP_STD_VER >= 14 using is_transparent = void; +#endif }; template <> diff --git a/libcxx/include/__iterator/iterator_traits.h b/libcxx/include/__iterator/iterator_traits.h index ebf315a53b6b7..be970affca2f2 100644 --- a/libcxx/include/__iterator/iterator_traits.h +++ b/libcxx/include/__iterator/iterator_traits.h @@ -351,16 +351,20 @@ struct iterator_traits<_Tp*> { template using __iterator_category _LIBCPP_NODEBUG = typename _Tp::iterator_category; +#if _LIBCPP_STD_VER >= 20 template using __iterator_concept _LIBCPP_NODEBUG = typename _Tp::iterator_concept; +#endif template using __has_iterator_category_convertible_to _LIBCPP_NODEBUG = is_convertible<__detected_or_t<__nat, __iterator_category, iterator_traits<_Tp> >, _Up>; +#if _LIBCPP_STD_VER >= 20 template using __has_iterator_concept_convertible_to _LIBCPP_NODEBUG = is_convertible<__detected_or_t<__nat, __iterator_concept, _Tp>, _Up>; +#endif template using __has_input_iterator_category _LIBCPP_NODEBUG = __has_iterator_category_convertible_to<_Tp, input_iterator_tag>;