提示信息"/>
C++(20):为[[nodiscard]]提供提示信息
C++17中引入了[[nodiscard]]以对一些被忽略的函数返回值进行警告。
C++(17):[[nodiscard]]编译属性_[[nodiscard]] c++-CSDN博客
C++20可以为[[nodiscard]]提供一个可选的提示信息
[[nodiscard("can't ignore")]] int fi()
{return 1;
}int main()
{fi();return 0;
}//编译警告warning: ignoring return value of 'int fi()', declared with attribute 'nodiscard': 'can't ignore' [-Wunused-result]
更多推荐
C++(20):为[[nodiscard]]提供提示信息
发布评论