[libcxx-commits] [libcxx] [libc++] Avoid constructing additional objects when using map::at (PR #157866)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Wed Sep 17 09:04:03 PDT 2025


================
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_IS_TRANSPARENTLY_COMPARABLE_H
+#define _LIBCPP___TYPE_TRAITS_IS_TRANSPARENTLY_COMPARABLE_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// Two types are considered transparently comparable if `comparator(key, arg)` is equivalent to `comparator(key,
+// <implicit cast to KeyT>(arg))`.
----------------
ldionne wrote:

```suggestion
// Two types are considered transparently comparable if `comparator(key, arg)` is equivalent to `comparator(key,
// <implicit cast to KeyT>(arg))`.
//
// This is different from `__is_transparent_v`, which is only a property of the comparator and doesn't provide
// additional semantic guarantees.
```

Also, we might want to move this into `is_transparent.h`, but no strong opinion here.

https://github.com/llvm/llvm-project/pull/157866


More information about the libcxx-commits mailing list