Back to TILs

C++ attributes

Table of contents

Brief

Attribute [[nodiscard]]

  auto lm = [] [[nodiscard]] () -> int { return 42; };
  lm();  // would emit a warning
attributes.cpp:27:5: warning: ignoring return value of function declared with 'nodiscard' attribute [-Wunused-result]
lm();
~~^~

## Output


```txt


References