[libcxx-commits] [libcxx] [libc++][NFC] Rename the template parameter of __make_transparent (PR #186435)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Fri Mar 13 09:13:31 PDT 2026


https://github.com/ldionne created https://github.com/llvm/llvm-project/pull/186435

Renaming from _Tp to _ArgumentType makes it clearer that we're passing the argument type intended for the comparator, which allows checking whether *that specific use* of the comparator would be transparent.

Fixes #186396

>From 6eabf412357476bf788eb294a88bb7ca385552b5 Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Fri, 13 Mar 2026 12:09:26 -0400
Subject: [PATCH] [libc++][NFC] Rename the template parameter of
 __make_transparent

Renaming from _Tp to _ArgumentType makes it clearer that we're passing
the argument type intended for the comparator, which allows checking
whether *that specific use* of the comparator would be transparent.

Fixes #186396
---
 libcxx/include/__functional/operations.h      |  8 +++----
 .../include/__type_traits/make_transparent.h  | 21 ++++++++++---------
 2 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/libcxx/include/__functional/operations.h b/libcxx/include/__functional/operations.h
index c0e719bb581b6..7a80dce648fa1 100644
--- a/libcxx/include/__functional/operations.h
+++ b/libcxx/include/__functional/operations.h
@@ -379,8 +379,8 @@ struct less<void> {
   typedef void is_transparent;
 };
 
-template <class _Tp>
-struct __make_transparent<_Tp, less<_Tp> > {
+template <class _ArgumentType>
+struct __make_transparent<_ArgumentType, less<_ArgumentType> > {
   using type _LIBCPP_NODEBUG = less<>;
 };
 
@@ -477,8 +477,8 @@ struct greater<void> {
 template <class _Tp, class _Up>
 inline const bool __desugars_to_v<__greater_tag, greater<>, _Tp, _Up> = true;
 
-template <class _Tp>
-struct __make_transparent<_Tp, greater<_Tp>> {
+template <class _ArgumentType>
+struct __make_transparent<_ArgumentType, greater<_ArgumentType>> {
   using type _LIBCPP_NODEBUG = greater<>;
 };
 
diff --git a/libcxx/include/__type_traits/make_transparent.h b/libcxx/include/__type_traits/make_transparent.h
index c2edf126d4990..d3bca66841072 100644
--- a/libcxx/include/__type_traits/make_transparent.h
+++ b/libcxx/include/__type_traits/make_transparent.h
@@ -22,29 +22,30 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 
 // __make_transparent tries to create a transparent comparator from its non-transparent counterpart, e.g. obtain
 // `less<>` from `less<T>`. This is useful in cases where conversions can be avoided (e.g. a string literal to a
-// std::string).
+// std::string). This depends on the argument type provided to the comparator, because a comparator might be
+// transparent for some argument types but not for others.
 
-template <class _Tp, class _Comparator>
+template <class _ArgumentType, class _Comparator>
 struct __make_transparent {
   using type _LIBCPP_NODEBUG = _Comparator;
 };
 
-template <class _Tp, class _Comparator>
-using __make_transparent_t _LIBCPP_NODEBUG = typename __make_transparent<_Tp, _Comparator>::type;
+template <class _ArgumentType, class _Comparator>
+using __make_transparent_t _LIBCPP_NODEBUG = typename __make_transparent<_ArgumentType, _Comparator>::type;
 
-template <class _Tp,
+template <class _ArgumentType,
           class _Comparator,
-          __enable_if_t<is_same<_Comparator, __make_transparent_t<_Tp, _Comparator> >::value, int> = 0>
+          __enable_if_t<is_same<_Comparator, __make_transparent_t<_ArgumentType, _Comparator> >::value, int> = 0>
 _LIBCPP_HIDE_FROM_ABI _Comparator& __as_transparent(_Comparator& __comp) {
   return __comp;
 }
 
-template <class _Tp,
+template <class _ArgumentType,
           class _Comparator,
-          __enable_if_t<!is_same<_Comparator, __make_transparent_t<_Tp, _Comparator> >::value, int> = 0>
-_LIBCPP_HIDE_FROM_ABI __make_transparent_t<_Tp, _Comparator> __as_transparent(_Comparator&) {
+          __enable_if_t<!is_same<_Comparator, __make_transparent_t<_ArgumentType, _Comparator> >::value, int> = 0>
+_LIBCPP_HIDE_FROM_ABI __make_transparent_t<_ArgumentType, _Comparator> __as_transparent(_Comparator&) {
   static_assert(is_empty<_Comparator>::value);
-  return __make_transparent_t<_Tp, _Comparator>();
+  return __make_transparent_t<_ArgumentType, _Comparator>();
 }
 
 _LIBCPP_END_NAMESPACE_STD



More information about the libcxx-commits mailing list