From 4ce650d61d24f4223cdfcd0fa53dd84bf90ba893 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Mon, 17 Dec 2018 17:27:43 -0800 Subject: [PATCH] Remove redundant move to avoid Wredundant-move with Clang Signed-off-by: Khem Raj --- include/internal/catch_session.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/include/internal/catch_session.cpp b/include/internal/catch_session.cpp index 0920521c00..6224fbe62b 100644 --- a/include/internal/catch_session.cpp +++ b/include/internal/catch_session.cpp @@ -42,14 +42,19 @@ namespace Catch { return createReporter(config->getReporterName(), config); } - auto multi = std::unique_ptr(new ListeningReporter); - + // On older platforms, returning std::unique_ptr + // when the return type is std::unique_ptr + // doesn't compile without a std::move call. However, this causes + // a warning on newer platforms. Thus, we have to work around + // it a bit and downcast the pointer manually. + auto ret = std::unique_ptr(new ListeningReporter); + auto& multi = static_cast(*ret); auto const& listeners = Catch::getRegistryHub().getReporterRegistry().getListeners(); for (auto const& listener : listeners) { - multi->addListener(listener->create(Catch::ReporterConfig(config))); + multi.addListener(listener->create(Catch::ReporterConfig(config))); } - multi->addReporter(createReporter(config->getReporterName(), config)); - return std::move(multi); + multi.addReporter(createReporter(config->getReporterName(), config)); + return ret; }