在C ++ 17之前指定[[nodiscard]]的方法

时间:2017-07-19 12:33:03

标签: c++

我需要非C ++ 17代码库中[[nodiscard]]属性的语义。我想在C ++ 17之前有编译器相关的方法来实现这一点。有谁知道这些?我对clang,gcc和MSVC感兴趣。

1 个答案:

答案 0 :(得分:11)

  • GCC / Clang:__attribute__((warn_unused_result))
  • MSVC:_Check_return_ _MSC_VER >= 1700(Visual Studio 2012)