2014-11-12 CPlusPlus11

Last edit

Summary: = The deprecated attribute To mark an entity as deprecated the attribute *deprecated* is introduced. The idea is to be able to mark things, . . .

Changed:

< To mark an entity as deprecated the attribute *deprecated* is introduced. The idea is to be able to mark things, although they are still working, that their use are being discouraged for some reason. The thought goes to things that will be removed in future releases but it is of course not limited to that.

to

> To mark an entity as deprecated the attribute **deprecated** is introduced. The idea is to be able to mark things, although they are still working, that their use are being discouraged for some reason. The thought goes to things that will be removed in future releases but it is of course not limited to that.


The deprecated attribute

To mark an entity as deprecated the attribute deprecated is introduced. The idea is to be able to mark things, although they are still working, that their use are being discouraged for some reason. The thought goes to things that will be removed in future releases but it is of course not limited to that.

This is different to most other C++-1y features a compile time only feature. It will produce a warning when the code is compiled. That is it.

The syntax is like this:

[[deprecated]]
int func(int i)
{
   ...

You can even add an explanation to why this function is deprecated and this string will be shown in the warning message by the compiler.

[[deprecated("Don't use this please, we are going to remove this next release or so")]]
int old(int i)
{
   ...

Most entities can be marked as deprecated this way. Here are some examples.

class [[deprecated]] C
{
   ...

class C2
{
public:
   [[deprecated]]
   int func(...
   ...