C ++ 14 permits the [[deprecated]] attribute to be applied to (as per 7.6.5 / 2) “declaration of a class, typedef name, variable, non-static data member, function, Enumeration or specialization pattern.” Especially there are no templates. So the template is given:
template<class T> class MyOldRefCountingPointer { ... };
I can blame, say, MyOldRefCountingPointer<void> ,
template<> class [[deprecated ("Use std::shared_ptr<void> instead of MyOldRefCountingPointer")]] MyOldRefCountingPointer<void> { ... };
but I can not judge the general pattern:
template<class T> class [[deprecated ("Use std::shared_ptr instead of MyOldRefCountingPointer")]] MyOldRefCountingPointer { ... };
Why are templates forbidden?
Refresh
An example of how an obsolete template can be used without warning:
template<class T> class [[deprecated]] OldClass {}; template<template<class> class C = OldClass> // use deprecated template as void f() // default template parameter { }
Neither g ++ nor Clang give warnings here. An example on Kolira .
source share