From d2f8165ec6085bfea891f0115fd3739939a1faed Mon Sep 17 00:00:00 2001 From: Christos Choutouridis Date: Wed, 29 Sep 2021 15:57:30 +0300 Subject: [PATCH] DEV: deque (and derived classes) have some extra noexcpets --- include/cont/deque.h | 8 ++++---- include/cont/edeque.h | 20 ++++++++++---------- include/cont/equeue.h | 10 +++++----- include/cont/queue.h | 10 +++++----- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/include/cont/deque.h b/include/cont/deque.h index c7771c0..8bcd979 100644 --- a/include/cont/deque.h +++ b/include/cont/deque.h @@ -164,7 +164,7 @@ class deque { } //! \brief Push an item in the front of the deque //! \param it The item to push - constexpr void push_front (const Data_t& it) { + constexpr void push_front (const Data_t& it) noexcept { if (full()) return; if constexpr (SemiAtomic) std::atomic_thread_fence(std::memory_order_acquire); @@ -174,7 +174,7 @@ class deque { } //! \brief Extract an item from the front of the deque and remove it from the deque //! \param it The item to push - constexpr Data_t pop_front () { + constexpr Data_t pop_front () noexcept { if (empty()) return Data_t{}; if constexpr (SemiAtomic) std::atomic_thread_fence(std::memory_order_acquire); @@ -182,7 +182,7 @@ class deque { } //! \brief Push an item in the back of the deque //! \param it The item to push - constexpr void push_back (const Data_t& it) { + constexpr void push_back (const Data_t& it) noexcept { if (full()) return; if constexpr (SemiAtomic) std::atomic_thread_fence(std::memory_order_acquire); @@ -192,7 +192,7 @@ class deque { } //! \brief Extract an item from the back of the deque and remove it from the deque //! \param it The item to push - constexpr Data_t pop_back () { + constexpr Data_t pop_back () noexcept { if (empty()) return Data_t{}; if constexpr (SemiAtomic) std::atomic_thread_fence(std::memory_order_acquire); diff --git a/include/cont/edeque.h b/include/cont/edeque.h index 8b614b5..146770e 100644 --- a/include/cont/edeque.h +++ b/include/cont/edeque.h @@ -130,7 +130,7 @@ class edeque : public deque { base_type() { } //! Size trigger constructor - constexpr edeque (size_match match, size_t size, callable_t&& fn) : + constexpr edeque (size_match match, size_t size, callable_t&& fn) noexcept : base_type(), mode_{match_mode::SIZE}, callback_{std::forward(fn)} { @@ -138,7 +138,7 @@ class edeque : public deque { trigger_.tsize.size = size; } //! Data trigger constructor - constexpr edeque (data_match match, Data_t value, callable_t&& fn) : + constexpr edeque (data_match match, Data_t value, callable_t&& fn) noexcept : base_type(), mode_{match_mode::DATA}, callback_{std::forward(fn)} { @@ -153,7 +153,7 @@ class edeque : public deque { //! \brief //! Manually checks the size trigger and calls it we have match. //! \return True if the callable has called. - bool check_trigger () { + bool check_trigger () noexcept { return check_trigger_size_(); } @@ -163,7 +163,7 @@ class edeque : public deque { //! \param match The match type //! \param size The size for with we check against //! \param fn The callable to call on match - void set_trigger (size_match match, size_t size, callable_t&& fn) { + void set_trigger (size_match match, size_t size, callable_t&& fn) noexcept { mode_ = match_mode::SIZE; trigger_.tsize.type = match; trigger_.tsize.size = size; @@ -176,7 +176,7 @@ class edeque : public deque { //! \param match The match type //! \param value The value for with we check against //! \param fn The callable to call on match - void set_trigger (data_match match, Data_t value, callable_t&& fn) { + void set_trigger (data_match match, Data_t value, callable_t&& fn) noexcept { mode_ = match_mode::DATA; trigger_.tdata.type = match; trigger_.tdata.value= value; @@ -184,7 +184,7 @@ class edeque : public deque { } //! \brief Manually clears the trigger - void clear_trigger () { + void clear_trigger () noexcept { mode_ = match_mode{}; trigger_ = trigger{}; callback_ = callable_t{}; @@ -193,20 +193,20 @@ class edeque : public deque { //! \name Base class overwrites //! @{ - void push_front (const Data_t& it) { + void push_front (const Data_t& it) noexcept { base_type::push_front(it); check_trigger_push_async_(it); } - Data_t pop_front () { + Data_t pop_front () noexcept { Data_t t = base_type::pop_front(); check_trigger_pop_async_(t); return t; } - void push_back (const Data_t& it) { + void push_back (const Data_t& it) noexcept { base_type::push_back(it); check_trigger_push_async_(it); } - Data_t pop_back () { + Data_t pop_back () noexcept { Data_t t = base_type::pop_back(); check_trigger_pop_async_(t); return t; diff --git a/include/cont/equeue.h b/include/cont/equeue.h index ec9a513..bf44ca3 100644 --- a/include/cont/equeue.h +++ b/include/cont/equeue.h @@ -92,26 +92,26 @@ class equeue : public edeque { public: //! \brief Push an item in the back of the queue //! \param it The item to push - void push (const Data_t& it) { + void push (const Data_t& it) noexcept { base_type::push_back(it); } //! \brief Extract an item from the front of the queue and remove it from the queue //! \param it The item to push - Data_t pop () { + Data_t pop () noexcept { return base_type::pop_front(); } //! \brief Push an item in the back of the queue //! \param it The item to push - equeue_t& operator<< (const Data_t& it) { + equeue_t& operator<< (const Data_t& it) noexcept { push(it); return *this; } //! \brief Push an item in the back of the queue //! \param it The item to push - equeue_t& operator>> (Data_t& it) { + equeue_t& operator>> (Data_t& it) noexcept { it = pop(); return *this; } @@ -136,7 +136,7 @@ class equeue : public edeque { * \return Reference to the returned item */ template > -Data_t& operator<< (Data_t& it, equeue& q) { +Data_t& operator<< (Data_t& it, equeue& q) noexcept { it = q.pop(); return it; } diff --git a/include/cont/queue.h b/include/cont/queue.h index db01aff..3cfcdd7 100644 --- a/include/cont/queue.h +++ b/include/cont/queue.h @@ -93,26 +93,26 @@ class queue : public deque { public: //! \brief Push an item in the back of the queue //! \param it The item to push - constexpr void push (const Data_t& it) { + constexpr void push (const Data_t& it) noexcept { base_type::push_back(it); } //! \brief Extract an item from the front of the queue and remove it from the queue //! \param it The item to push - constexpr Data_t pop () { + constexpr Data_t pop () noexcept { return base_type::pop_front(); } //! \brief Push an item in the back of the queue //! \param it The item to push - constexpr queue_t& operator<< (const Data_t& it) { + constexpr queue_t& operator<< (const Data_t& it) noexcept { push(it); return *this; } //! \brief Pop an item from the front of the queue //! \param it The item to write to - constexpr queue_t& operator>> (Data_t& it) { + constexpr queue_t& operator>> (Data_t& it) noexcept { it = pop(); return *this; } @@ -134,7 +134,7 @@ class queue : public deque { * \return Reference to the returned item */ template -constexpr Data_t& operator<< (Data_t& it, queue& q) { +constexpr Data_t& operator<< (Data_t& it, queue& q) noexcept { it = q.pop(); return it; }