[libcxx-commits] [PATCH] D91311: Add new 'preferred_name' attribute.
Arthur O'Dwyer via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Nov 13 06:37:26 PST 2020
Quuxplusone added inline comments.
================
Comment at: libcxx/include/regex:2520
+ _LIBCPP_PREFERRED_NAME(wregex)
+ basic_regex
{
----------------
Why does this attribute go on the class template? Shouldn't it be an attribute on the typedef, so that you don't have to repeat yourself? I mean, I'd much rather see
template<class T> class BasicFoo { };
using [[preferred]] Foo = BasicFoo<A>;
using [[preferred]] WFoo = BasicFoo<B>;
than
template<class> class BasicFoo;
using Foo = BasicFoo<A>;
using WFoo = BasicFoo<B>;
template<class T> class [[preferred(Foo, WFoo)]] BasicFoo { };
The latter repeats every identifier one extra time, compared to the former.
And then, in fact, couldn't you go one step further and say that typedefs in the same scope as the class template itself should //always// implicitly have this attribute? Even if the attribute doesn't appear in the source code, we still want to print `basic_regex<char>` as `regex`, right? It shouldn't cost any additional work for the compiler to figure that out.
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