13

I need the semantics of the [[nodiscard]] attribute in a non-C++17 codebase. I guess there are compiler dependent ways of achieving this before C++17. Does anyone know these? I am interested in the ones for clang,gcc, and MSVC.

Alex Guteniev
  • 12,039
  • 2
  • 34
  • 79
gexicide
  • 38,535
  • 21
  • 92
  • 152

1 Answers1

15
  • GCC/Clang: __attribute__((warn_unused_result))
  • MSVC: _Check_return_ for _MSC_VER >= 1700 (Visual Studio 2012)
Nikolai Shalakin
  • 1,349
  • 2
  • 13
  • 25