From 3689b0853594067d990fab3c82b0cd0f2843ec64 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Thu, 22 Mar 2018 14:57:34 +1100 Subject: [PATCH] parallel/queue: add nodiscard to push/pop Users _must_ check the return value otherwise they've no indication whether anything happened... This is a pretty common mistake because it looks a lot like a typical push/pop operation. --- parallel/queue.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/parallel/queue.hpp b/parallel/queue.hpp index 46ae8f07..3f6a7e56 100644 --- a/parallel/queue.hpp +++ b/parallel/queue.hpp @@ -66,7 +66,7 @@ namespace util::parallel { /// if updating the write pointer fails we bail and return false. /// else, we will be able to commit the data and return true. bool - push (const ValueT &val) + push [[nodiscard]] (const ValueT &val) { do { // find our current and next indices, checking there is @@ -119,7 +119,7 @@ namespace util::parallel { /// importantly: the contents of the provided reference may have been /// overwritten, but should not be used unless true was returned. bool - pop (ValueT &out) + pop [[nodiscard]] (ValueT &out) { do {