From a96793ec8c496eec19daf68f3aa0c4eded2ea166 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Fri, 20 Dec 2019 22:20:07 +0100 Subject: [PATCH 1/1] [sonar] "std::forward" should only be called on a forwarding reference. --- include/xbt/functional.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/xbt/functional.hpp b/include/xbt/functional.hpp index a2ddfa7280..1fefcd8473 100644 --- a/include/xbt/functional.hpp +++ b/include/xbt/functional.hpp @@ -192,7 +192,7 @@ private: { const static TaskVtable vtable { // Call: - [](TaskUnion& buffer, Args... args) { + [](TaskUnion& buffer, Args&&... args) { F* src = reinterpret_cast(&buffer); F code = std::move(*src); src->~F(); @@ -221,7 +221,7 @@ private: { const static TaskVtable vtable { // Call: - [](TaskUnion& buffer, Args... args) { + [](TaskUnion& buffer, Args&&... args) { // Delete F when we go out of scope: std::unique_ptr code(*reinterpret_cast(&buffer)); return (*code)(std::forward(args)...); @@ -244,7 +244,7 @@ public: operator bool() const { return vtable_ != nullptr; } bool operator!() const { return vtable_ == nullptr; } - R operator()(Args... args) + R operator()(Args&&... args) { if (vtable_ == nullptr) throw std::bad_function_call(); -- 2.20.1