Monday, September 25, 2017

C++14: The attribute [[deprecated]] Attribute

C++14 added the [[deprecated]] attribute to mark functions in the code as being deprecated. Here is an example:

[[deprecated]]
/////////////////////////////////////////////////
void f()
{

}

[[deprecated("My additional message.")]]
void g()
{

}

int main()
{
  f();
  g();
  return 0;
}
// Compiler Output: warning C4996: 'f': was declared deprecated
//                  warning C4996: 'g': My additional message.
Reference: https://en.wikipedia.org/wiki/C%2B%2B14#The_attribute_.5B.5Bdeprecated.5D.5D

No comments:

Post a Comment