Skip to content

Conversation

@frederick-vs-ja
Copy link
Contributor

Before C++14/20, is_transparent and iterator_concept were not reserved at all respectively, and users might define them as macros.

Before C++14/20, `is_transparent` and `iterator_concept` were not
reserved at all respectively, and users might define them as macros.
@frederick-vs-ja frederick-vs-ja requested a review from a team as a code owner November 5, 2025 03:09
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Nov 5, 2025
@llvmbot
Copy link
Member

llvmbot commented Nov 5, 2025

@llvm/pr-subscribers-libcxx

Author: A. Jiang (frederick-vs-ja)

Changes

Before C++14/20, is_transparent and iterator_concept were not reserved at all respectively, and users might define them as macros.


Full diff: https://github.com/llvm/llvm-project/pull/166495.diff

3 Files Affected:

  • (modified) libcxx/include/__filesystem/path_iterator.h (+3-1)
  • (modified) libcxx/include/__functional/identity.h (+2)
  • (modified) libcxx/include/__iterator/iterator_traits.h (+4)
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 <class _Tp>
 using __iterator_category _LIBCPP_NODEBUG = typename _Tp::iterator_category;
 
+#if _LIBCPP_STD_VER >= 20
 template <class _Tp>
 using __iterator_concept _LIBCPP_NODEBUG = typename _Tp::iterator_concept;
+#endif
 
 template <class _Tp, class _Up>
 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 <class _Tp, class _Up>
 using __has_iterator_concept_convertible_to _LIBCPP_NODEBUG =
     is_convertible<__detected_or_t<__nat, __iterator_concept, _Tp>, _Up>;
+#endif
 
 template <class _Tp>
 using __has_input_iterator_category _LIBCPP_NODEBUG = __has_iterator_category_convertible_to<_Tp, input_iterator_tag>;

@frederick-vs-ja
Copy link
Contributor Author

Test coverage might be desired but I'm not sure whether and how to add it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants