GCC does support deprecating template alias since version 4.9 (since 4.7 with __attribute__(deprecated)
). This is a test case comparing typedef and template alias:
template <class T>
struct NewClassName
{
// ...
};
template <class T> using OldClassNameUsing [[deprecated]]
= NewClassName<T>;
typedef NewClassName<int> OldClassNameTypedef [[deprecated]];
int main()
{
OldClassNameUsing<int> objectUsing;
OldClassNameTypedef objectTypedef;
return 0;
}
The reason why it did not work for me was that I did not create an object of the OldClassNameUsing but accessed static members like OldClassNameUsing::myFunction(). This does never trigger a deprecation warning unless the function itself is deprecated.
Clang does not yet support deprecating a template alias - tested with version 13. The corresponding feature request is
http://llvm.org/bugs/show_bug.cgi?id=17862 https://github.com/llvm/llvm-project/issues/18236.