[libcxx-commits] [libcxx] [libc++] Add `__is_transparently_comparable_v` specializations for `basic_string_view` (PR #195871)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Tue Aug 4 02:54:54 PDT 2026


philnik777 wrote:

> > This introduces an extension: https://godbolt.org/z/xej3Ez54T
> 
> It is true that this introduces an extension IIUC, specifically `map<string, V>::find(string_view)` is not supposed to compile but it does after this patch. On the other hand, it does make sense to say that `string` and `string_view` are transparently comparable, I think.

I don't think it does. This is what we claim is a transparently comparatble `key, value`:
```
// Two types are considered transparently comparable if `comparator(key, arg)` is equivalent to `comparator(key,
// <implicit cast to KeyT>(arg))`
```

Since `string_view` is _not_ implicitly convertible to `string`, at least according to our current definition of `__is_transparently_comparable_v`, `string, string_view` should be false.
We can make `string_view, string` true, but I don't really see the benefit there.


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


More information about the libcxx-commits mailing list