From df7248039553b3ebd338380c3ef0428b0e046e79 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 14 Aug 2020 09:38:45 -0400 Subject: common: Make use of [[nodiscard]] where applicable Now that clang-format makes [[nodiscard]] attributes format sensibly, we can apply them to several functions within the common library to allow the compiler to complain about any misuses of the functions. --- src/common/thread_queue_list.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/common/thread_queue_list.h') diff --git a/src/common/thread_queue_list.h b/src/common/thread_queue_list.h index 791f99a8c..def9e5d8d 100644 --- a/src/common/thread_queue_list.h +++ b/src/common/thread_queue_list.h @@ -18,14 +18,14 @@ struct ThreadQueueList { using Priority = unsigned int; // Number of priority levels. (Valid levels are [0..NUM_QUEUES).) - static const Priority NUM_QUEUES = N; + static constexpr Priority NUM_QUEUES = N; ThreadQueueList() { first = nullptr; } // Only for debugging, returns priority level. - Priority contains(const T& uid) const { + [[nodiscard]] Priority contains(const T& uid) const { for (Priority i = 0; i < NUM_QUEUES; ++i) { const Queue& cur = queues[i]; if (std::find(cur.data.cbegin(), cur.data.cend(), uid) != cur.data.cend()) { @@ -36,7 +36,7 @@ struct ThreadQueueList { return -1; } - T get_first() const { + [[nodiscard]] T get_first() const { const Queue* cur = first; while (cur != nullptr) { if (!cur->data.empty()) { @@ -49,7 +49,7 @@ struct ThreadQueueList { } template - T get_first_filter(UnaryPredicate filter) const { + [[nodiscard]] T get_first_filter(UnaryPredicate filter) const { const Queue* cur = first; while (cur != nullptr) { if (!cur->data.empty()) { @@ -129,7 +129,7 @@ struct ThreadQueueList { first = nullptr; } - bool empty(Priority priority) const { + [[nodiscard]] bool empty(Priority priority) const { const Queue* cur = &queues[priority]; return cur->data.empty(); } -- cgit v1.2.3