[libcxx-commits] [PATCH] D91311: Add new 'preferred_name' attribute.

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Nov 17 14:03:01 PST 2020


ldionne added subscribers: david_stone, mattcalabrese, mpark.
ldionne added a comment.

In D91311#2400917 <https://reviews.llvm.org/D91311#2400917>, @dblaikie wrote:

> How would that work for users - they would get error messages from the compiler using type names that don't exist in the source code? I'd have thought that would be quite confusing.

Yes, if a library author decides to say something like:

  template<class _CharT, class _Traits>
  class [[preferred_name(basic_string_view<char>, "ahaha I'm such a troll")]]
  basic_string_view {
      ...
  };

Then you might get compiler errors that are not super helpful. I don't think the fact that such nonsense is doable means that we shouldn't give this control to library authors.

For instance, I can easily imagine a library that provides an API where some types shouldn't be named (for example expression templates). In that case, you might want to describe a type by a string along the lines of `decltype(some-expression)`, which could potentially be a lot more useful than the ability to refer to a typedef. Does this sort of usage ring true to someone else?

Pinging fellow library folks in case they have an opinion. @mattcalabrese @david_stone @mpark


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91311/new/

https://reviews.llvm.org/D91311



More information about the libcxx-commits mailing list