From 928ecbaccf7f4ae8dfae2c1a649e2ee461bcb450 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Sat, 21 Aug 2021 21:00:00 +0200 Subject: [PATCH] Change callable/model::clone to return a unique_ptr --- src/catch2/benchmark/detail/catch_benchmark_function.hpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/catch2/benchmark/detail/catch_benchmark_function.hpp b/src/catch2/benchmark/detail/catch_benchmark_function.hpp index d70f5200..655c8635 100644 --- a/src/catch2/benchmark/detail/catch_benchmark_function.hpp +++ b/src/catch2/benchmark/detail/catch_benchmark_function.hpp @@ -36,7 +36,7 @@ namespace Catch { private: struct callable { virtual void call(Chronometer meter) const = 0; - virtual callable* clone() const = 0; + virtual Catch::Detail::unique_ptr clone() const = 0; virtual ~callable(); // = default; callable() = default; @@ -48,7 +48,9 @@ namespace Catch { model(Fun&& fun_) : fun(CATCH_MOVE(fun_)) {} model(Fun const& fun_) : fun(fun_) {} - model* clone() const override { return new model(*this); } + Catch::Detail::unique_ptr clone() const override { + return Catch::Detail::make_unique>( *this ); + } void call(Chronometer meter) const override { call(meter, is_callable()); @@ -90,7 +92,7 @@ namespace Catch { } BenchmarkFunction& operator=(BenchmarkFunction const& that) { - f.reset(that.f->clone()); + f = that.f->clone(); return *this; }