MPMCQueue icon indicating copy to clipboard operation
MPMCQueue copied to clipboard

Update MPMCQueue.h and add [[nodiscard]] attributes to emty(), idx(), turn(), size()

Open pascalpha opened this issue 3 years ago • 5 comments

Add [[nodiscard]] attributes

pascalpha avatar Dec 13 '21 01:12 pascalpha

Nice, I was going to add this myself. The question is if I should bump the required C++ standard to C++17 which includes [[nodiscard]] or use macros to support C++11.

rigtorp avatar Dec 14 '21 15:12 rigtorp

I was under the impression that unknown attributes are ignored by major compilers. After some research it turns out this is a c++ 17 feature. Macros are better suited then.

ghost avatar Dec 14 '21 15:12 ghost

This approach seems to work well https://github.com/rigtorp/SPSCQueue/pull/31

rigtorp avatar Dec 14 '21 19:12 rigtorp

Done. Also, if not too persnickety, I see no reason to #include a pure C header <stdlib.h> instead of <cstdlib>, especially as the other two C headers (cassert, cstddef) were included that way.

ghost avatar Dec 15 '21 01:12 ghost

Done. Also, if not too persnickety, I see no reason to #include a pure C header <stdlib.h> instead of , especially as the other two C headers (cassert, cstddef) were included that way.

Yes I agree.

Shouldn't try_pop, try_push etc also have NODISCARD?

rigtorp avatar Dec 20 '21 19:12 rigtorp