[libcxx-commits] [libcxx] [libc++] Refactor __is_transparent_v to make it clear what it depends on (PR #186419)
via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Mar 13 08:35:26 PDT 2026
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff origin/main HEAD --extensions ,h -- libcxx/include/__functional/is_transparent.h libcxx/include/map libcxx/include/set libcxx/include/unordered_map libcxx/include/unordered_set --diff_from_common_commit
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/libcxx/include/map b/libcxx/include/map
index de76ef9cc..b7031aeb5 100644
--- a/libcxx/include/map
+++ b/libcxx/include/map
@@ -1313,15 +1313,15 @@ public:
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __tree_.find(__k); }
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __tree_.find(__k); }
# if _LIBCPP_STD_VER >= 14
- template <typename _K2, class _Comp = _Compare,
- enable_if_t<__is_transparent_v<_Comp> || __is_transparently_comparable_v<_Comp, key_type, _K2>,
- int> = 0>
+ template <typename _K2,
+ class _Comp = _Compare,
+ enable_if_t<__is_transparent_v<_Comp> || __is_transparently_comparable_v<_Comp, key_type, _K2>, int> = 0>
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) {
return __tree_.find(__k);
}
- template <typename _K2, class _Comp = _Compare,
- enable_if_t<__is_transparent_v<_Comp> || __is_transparently_comparable_v<_Comp, key_type, _K2>,
- int> = 0>
+ template <typename _K2,
+ class _Comp = _Compare,
+ enable_if_t<__is_transparent_v<_Comp> || __is_transparently_comparable_v<_Comp, key_type, _K2>, int> = 0>
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const {
return __tree_.find(__k);
}
@@ -1339,9 +1339,9 @@ public:
# if _LIBCPP_STD_VER >= 20
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); }
- template <typename _K2, class _Comp = _Compare,
- enable_if_t<__is_transparent_v<_Comp> || __is_transparently_comparable_v<_Comp, key_type, _K2>,
- int> = 0>
+ template <typename _K2,
+ class _Comp = _Compare,
+ enable_if_t<__is_transparent_v<_Comp> || __is_transparently_comparable_v<_Comp, key_type, _K2>, int> = 0>
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const {
return find(__k) != end();
}
@@ -1358,16 +1358,16 @@ public:
// The transparent versions of the lookup functions use the _multi version, since a non-element key is allowed to
// match multiple elements.
# if _LIBCPP_STD_VER >= 14
- template <typename _K2, class _Comp = _Compare,
- enable_if_t<__is_transparent_v<_Comp> || __is_transparently_comparable_v<_Comp, key_type, _K2>,
- int> = 0>
+ template <typename _K2,
+ class _Comp = _Compare,
+ enable_if_t<__is_transparent_v<_Comp> || __is_transparently_comparable_v<_Comp, key_type, _K2>, int> = 0>
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _K2& __k) {
return __tree_.__lower_bound_multi(__k);
}
- template <typename _K2, class _Comp = _Compare,
- enable_if_t<__is_transparent_v<_Comp> || __is_transparently_comparable_v<_Comp, key_type, _K2>,
- int> = 0>
+ template <typename _K2,
+ class _Comp = _Compare,
+ enable_if_t<__is_transparent_v<_Comp> || __is_transparently_comparable_v<_Comp, key_type, _K2>, int> = 0>
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _K2& __k) const {
return __tree_.__lower_bound_multi(__k);
}
@@ -1382,15 +1382,15 @@ public:
}
# if _LIBCPP_STD_VER >= 14
- template <typename _K2, class _Comp = _Compare,
- enable_if_t<__is_transparent_v<_Comp> || __is_transparently_comparable_v<_Comp, key_type, _K2>,
- int> = 0>
+ template <typename _K2,
+ class _Comp = _Compare,
+ enable_if_t<__is_transparent_v<_Comp> || __is_transparently_comparable_v<_Comp, key_type, _K2>, int> = 0>
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _K2& __k) {
return __tree_.__upper_bound_multi(__k);
}
- template <typename _K2, class _Comp = _Compare,
- enable_if_t<__is_transparent_v<_Comp> || __is_transparently_comparable_v<_Comp, key_type, _K2>,
- int> = 0>
+ template <typename _K2,
+ class _Comp = _Compare,
+ enable_if_t<__is_transparent_v<_Comp> || __is_transparently_comparable_v<_Comp, key_type, _K2>, int> = 0>
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _K2& __k) const {
return __tree_.__upper_bound_multi(__k);
}
diff --git a/libcxx/include/unordered_map b/libcxx/include/unordered_map
index 270fc19c0..6afa5c390 100644
--- a/libcxx/include/unordered_map
+++ b/libcxx/include/unordered_map
@@ -1216,12 +1216,16 @@ public:
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __table_.find(__k); }
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __table_.find(__k); }
# if _LIBCPP_STD_VER >= 20
- template <class _K2, class _Hasher = hasher, class _Comp = key_equal,
+ template <class _K2,
+ class _Hasher = hasher,
+ class _Comp = key_equal,
enable_if_t<__is_transparent_v<_Hasher> && __is_transparent_v<_Comp>>* = nullptr>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) {
return __table_.find(__k);
}
- template <class _K2, class _Hasher = hasher, class _Comp = key_equal,
+ template <class _K2,
+ class _Hasher = hasher,
+ class _Comp = key_equal,
enable_if_t<__is_transparent_v<_Hasher> && __is_transparent_v<_Comp>>* = nullptr>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const {
return __table_.find(__k);
@@ -1232,7 +1236,9 @@ public:
return __table_.__count_unique(__k);
}
# if _LIBCPP_STD_VER >= 20
- template <class _K2, class _Hasher = hasher, class _Comp = key_equal,
+ template <class _K2,
+ class _Hasher = hasher,
+ class _Comp = key_equal,
enable_if_t<__is_transparent_v<_Hasher> && __is_transparent_v<_Comp>>* = nullptr>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const {
return __table_.__count_unique(__k);
@@ -1242,7 +1248,9 @@ public:
# if _LIBCPP_STD_VER >= 20
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); }
- template <class _K2, class _Hasher = hasher, class _Comp = key_equal,
+ template <class _K2,
+ class _Hasher = hasher,
+ class _Comp = key_equal,
enable_if_t<__is_transparent_v<_Hasher> && __is_transparent_v<_Comp>>* = nullptr>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const {
return find(__k) != end();
@@ -1256,12 +1264,16 @@ public:
return __table_.__equal_range_unique(__k);
}
# if _LIBCPP_STD_VER >= 20
- template <class _K2, class _Hasher = hasher, class _Comp = key_equal,
+ template <class _K2,
+ class _Hasher = hasher,
+ class _Comp = key_equal,
enable_if_t<__is_transparent_v<_Hasher> && __is_transparent_v<_Comp>>* = nullptr>
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) {
return __table_.__equal_range_unique(__k);
}
- template <class _K2, class _Hasher = hasher, class _Comp = key_equal,
+ template <class _K2,
+ class _Hasher = hasher,
+ class _Comp = key_equal,
enable_if_t<__is_transparent_v<_Hasher> && __is_transparent_v<_Comp>>* = nullptr>
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const {
return __table_.__equal_range_unique(__k);
@@ -1942,12 +1954,16 @@ public:
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __table_.find(__k); }
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __table_.find(__k); }
# if _LIBCPP_STD_VER >= 20
- template <class _K2, class _Hasher = hasher, class _Comp = key_equal,
+ template <class _K2,
+ class _Hasher = hasher,
+ class _Comp = key_equal,
enable_if_t<__is_transparent_v<_Hasher> && __is_transparent_v<_Comp>>* = nullptr>
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) {
return __table_.find(__k);
}
- template <class _K2, class _Hasher = hasher, class _Comp = key_equal,
+ template <class _K2,
+ class _Hasher = hasher,
+ class _Comp = key_equal,
enable_if_t<__is_transparent_v<_Hasher> && __is_transparent_v<_Comp>>* = nullptr>
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const {
return __table_.find(__k);
@@ -1958,7 +1974,9 @@ public:
return __table_.__count_multi(__k);
}
# if _LIBCPP_STD_VER >= 20
- template <class _K2, class _Hasher = hasher, class _Comp = key_equal,
+ template <class _K2,
+ class _Hasher = hasher,
+ class _Comp = key_equal,
enable_if_t<__is_transparent_v<_Hasher> && __is_transparent_v<_Comp>>* = nullptr>
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const {
return __table_.__count_multi(__k);
@@ -1968,7 +1986,9 @@ public:
# if _LIBCPP_STD_VER >= 20
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); }
- template <class _K2, class _Hasher = hasher, class _Comp = key_equal,
+ template <class _K2,
+ class _Hasher = hasher,
+ class _Comp = key_equal,
enable_if_t<__is_transparent_v<_Hasher> && __is_transparent_v<_Comp>>* = nullptr>
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const {
return find(__k) != end();
@@ -1982,12 +2002,16 @@ public:
return __table_.__equal_range_multi(__k);
}
# if _LIBCPP_STD_VER >= 20
- template <class _K2, class _Hasher = hasher, class _Comp = key_equal,
+ template <class _K2,
+ class _Hasher = hasher,
+ class _Comp = key_equal,
enable_if_t<__is_transparent_v<_Hasher> && __is_transparent_v<_Comp>>* = nullptr>
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) {
return __table_.__equal_range_multi(__k);
}
- template <class _K2, class _Hasher = hasher, class _Comp = key_equal,
+ template <class _K2,
+ class _Hasher = hasher,
+ class _Comp = key_equal,
enable_if_t<__is_transparent_v<_Hasher> && __is_transparent_v<_Comp>>* = nullptr>
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const {
return __table_.__equal_range_multi(__k);
diff --git a/libcxx/include/unordered_set b/libcxx/include/unordered_set
index e114fa194..45a36f349 100644
--- a/libcxx/include/unordered_set
+++ b/libcxx/include/unordered_set
@@ -844,12 +844,16 @@ public:
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __table_.find(__k); }
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __table_.find(__k); }
# if _LIBCPP_STD_VER >= 20
- template <class _K2, class _Hasher = hasher, class _Comp = key_equal,
+ template <class _K2,
+ class _Hasher = hasher,
+ class _Comp = key_equal,
enable_if_t<__is_transparent_v<_Hasher> && __is_transparent_v<_Comp>>* = nullptr>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) {
return __table_.find(__k);
}
- template <class _K2, class _Hasher = hasher, class _Comp = key_equal,
+ template <class _K2,
+ class _Hasher = hasher,
+ class _Comp = key_equal,
enable_if_t<__is_transparent_v<_Hasher> && __is_transparent_v<_Comp>>* = nullptr>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const {
return __table_.find(__k);
@@ -860,7 +864,9 @@ public:
return __table_.__count_unique(__k);
}
# if _LIBCPP_STD_VER >= 20
- template <class _K2, class _Hasher = hasher, class _Comp = key_equal,
+ template <class _K2,
+ class _Hasher = hasher,
+ class _Comp = key_equal,
enable_if_t<__is_transparent_v<_Hasher> && __is_transparent_v<_Comp>>* = nullptr>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const {
return __table_.__count_unique(__k);
@@ -870,7 +876,9 @@ public:
# if _LIBCPP_STD_VER >= 20
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); }
- template <class _K2, class _Hasher = hasher, class _Comp = key_equal,
+ template <class _K2,
+ class _Hasher = hasher,
+ class _Comp = key_equal,
enable_if_t<__is_transparent_v<_Hasher> && __is_transparent_v<_Comp>>* = nullptr>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const {
return find(__k) != end();
@@ -884,12 +892,16 @@ public:
return __table_.__equal_range_unique(__k);
}
# if _LIBCPP_STD_VER >= 20
- template <class _K2, class _Hasher = hasher, class _Comp = key_equal,
+ template <class _K2,
+ class _Hasher = hasher,
+ class _Comp = key_equal,
enable_if_t<__is_transparent_v<_Hasher> && __is_transparent_v<_Comp>>* = nullptr>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) {
return __table_.__equal_range_unique(__k);
}
- template <class _K2, class _Hasher = hasher, class _Comp = key_equal,
+ template <class _K2,
+ class _Hasher = hasher,
+ class _Comp = key_equal,
enable_if_t<__is_transparent_v<_Hasher> && __is_transparent_v<_Comp>>* = nullptr>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const {
return __table_.__equal_range_unique(__k);
@@ -1449,12 +1461,16 @@ public:
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __table_.find(__k); }
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __table_.find(__k); }
# if _LIBCPP_STD_VER >= 20
- template <class _K2, class _Hasher = hasher, class _Comp = key_equal,
+ template <class _K2,
+ class _Hasher = hasher,
+ class _Comp = key_equal,
enable_if_t<__is_transparent_v<_Hasher> && __is_transparent_v<_Comp>>* = nullptr>
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) {
return __table_.find(__k);
}
- template <class _K2, class _Hasher = hasher, class _Comp = key_equal,
+ template <class _K2,
+ class _Hasher = hasher,
+ class _Comp = key_equal,
enable_if_t<__is_transparent_v<_Hasher> && __is_transparent_v<_Comp>>* = nullptr>
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const {
return __table_.find(__k);
@@ -1465,7 +1481,9 @@ public:
return __table_.__count_multi(__k);
}
# if _LIBCPP_STD_VER >= 20
- template <class _K2, class _Hasher = hasher, class _Comp = key_equal,
+ template <class _K2,
+ class _Hasher = hasher,
+ class _Comp = key_equal,
enable_if_t<__is_transparent_v<_Hasher> && __is_transparent_v<_Comp>>* = nullptr>
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const {
return __table_.__count_multi(__k);
@@ -1475,7 +1493,9 @@ public:
# if _LIBCPP_STD_VER >= 20
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); }
- template <class _K2, class _Hasher = hasher, class _Comp = key_equal,
+ template <class _K2,
+ class _Hasher = hasher,
+ class _Comp = key_equal,
enable_if_t<__is_transparent_v<_Hasher> && __is_transparent_v<_Comp>>* = nullptr>
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const {
return find(__k) != end();
@@ -1489,12 +1509,16 @@ public:
return __table_.__equal_range_multi(__k);
}
# if _LIBCPP_STD_VER >= 20
- template <class _K2, class _Hasher = hasher, class _Comp = key_equal,
+ template <class _K2,
+ class _Hasher = hasher,
+ class _Comp = key_equal,
enable_if_t<__is_transparent_v<_Hasher> && __is_transparent_v<_Comp>>* = nullptr>
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) {
return __table_.__equal_range_multi(__k);
}
- template <class _K2, class _Hasher = hasher, class _Comp = key_equal,
+ template <class _K2,
+ class _Hasher = hasher,
+ class _Comp = key_equal,
enable_if_t<__is_transparent_v<_Hasher> && __is_transparent_v<_Comp>>* = nullptr>
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const {
return __table_.__equal_range_multi(__k);
``````````
</details>
https://github.com/llvm/llvm-project/pull/186419
More information about the libcxx-commits
mailing list