【问题标题】:How to apply the deprecated attribute to a using statement如何将不推荐使用的属性应用于 using 语句
【发布时间】:2018-06-15 20:10:38
【问题描述】:

如何将不推荐使用的属性应用于 using 语句,我可以将其应用于 typedef 而不是 using 似乎很奇怪

// Cannot do this
[[deprecated("Use a real int you wimp")]]
using Foo = int;

// This works just fine
[[deprecated("Use a real int you wimp")]]
typedef int Bar;

int main(int, char *[])
{
    Foo i = 43;

    (void)i;

    Bar j = 34;

    (void)j;
    return 0;
}

【问题讨论】:

    标签: attributes c++14 deprecated type-alias


    【解决方案1】:

    Like this:

    using Foo [[deprecated("Use a real int you wimp")]] = int;
    

    【讨论】:

      猜你喜欢
      • 2013-01-11
      • 1970-01-01
      • 1970-01-01
      • 2017-12-07
      • 1970-01-01
      • 2015-10-22
      • 1970-01-01
      • 1970-01-01
      • 2011-05-08
      相关资源
      最近更新 更多