From 176eed4dc76acb9369714e600875c0df5aceb04e Mon Sep 17 00:00:00 2001 From: heck Date: Wed, 14 Dec 2022 16:44:40 +0100 Subject: [PATCH] Enhancement: correct emplace_ functions using perfect-forwarding --- src/locked_queue.hh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/locked_queue.hh b/src/locked_queue.hh index 171e8d8..831f867 100644 --- a/src/locked_queue.hh +++ b/src/locked_queue.hh @@ -137,20 +137,22 @@ namespace utility { _cv.notify_one(); } - void emplace_back(const T&& data) + template< class... Args > + void emplace_back( Args&&... args ) { { Lock L(_mtx); - _q.emplace_back(data); + _q.emplace_back( std::forward(args)... ); } _cv.notify_one(); } - void emplace_front(const T&& data) + template< class... Args > + void emplace_front( Args&&... args ) { { Lock L(_mtx); - _q.emplace_front(data); + _q.emplace_front( std::forward(args)... ); } _cv.notify_one(); }