From 3ae3c86937c7ffc45d24e36a33560cd63ebb900b Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 27 Sep 2022 18:28:26 -0400 Subject: Use std::make_unique --- .clang-tidy | 1 - src/ingen/ingen.cpp | 3 +-- src/server/CompiledGraph.cpp | 3 ++- src/server/PortAudioDriver.cpp | 3 +-- src/server/Task.cpp | 3 ++- src/server/Task.hpp | 2 +- tests/ingen_bench.cpp | 3 +-- tests/ingen_test.cpp | 2 +- 8 files changed, 9 insertions(+), 11 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 69353fab..01ee20da 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -20,7 +20,6 @@ Checks: > -llvmlibc-*, -misc-unused-parameters, -modernize-concat-nested-namespaces, - -modernize-make-unique, -modernize-pass-by-value, -modernize-return-braced-init-list, -modernize-use-nodiscard, diff --git a/src/ingen/ingen.cpp b/src/ingen/ingen.cpp index b19e6423..06d990f2 100644 --- a/src/ingen/ingen.cpp +++ b/src/ingen/ingen.cpp @@ -99,8 +99,7 @@ run(int argc, char** argv) { // Create world try { - world = std::unique_ptr( - new ingen::World(nullptr, nullptr, nullptr)); + world = std::make_unique(nullptr, nullptr, nullptr); world->load_configuration(argc, argv); if (argc <= 1) { world->conf().print_usage("ingen", std::cout); diff --git a/src/server/CompiledGraph.cpp b/src/server/CompiledGraph.cpp index 103d27a3..f03187ae 100644 --- a/src/server/CompiledGraph.cpp +++ b/src/server/CompiledGraph.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include namespace ingen { @@ -71,7 +72,7 @@ has_provider_with_many_dependants(const BlockImpl* n) } CompiledGraph::CompiledGraph(GraphImpl* graph) - : _master(std::unique_ptr(new Task(Task::Mode::SEQUENTIAL))) + : _master{std::make_unique(Task::Mode::SEQUENTIAL)} { compile_graph(graph); } diff --git a/src/server/PortAudioDriver.cpp b/src/server/PortAudioDriver.cpp index c04e83d9..c80b25f3 100644 --- a/src/server/PortAudioDriver.cpp +++ b/src/server/PortAudioDriver.cpp @@ -85,8 +85,7 @@ PortAudioDriver::attach() _sample_rate = in_dev->defaultSampleRate; - _timer = std::unique_ptr( - new FrameTimer(_block_length, _sample_rate)); + _timer = std::make_unique(_block_length, _sample_rate); return true; } diff --git a/src/server/Task.cpp b/src/server/Task.cpp index 43db78e8..089a2f46 100644 --- a/src/server/Task.cpp +++ b/src/server/Task.cpp @@ -22,6 +22,7 @@ #include "raul/Path.hpp" #include +#include namespace ingen { namespace server { @@ -116,7 +117,7 @@ Task::simplify(std::unique_ptr&& task) return std::move(task); } - std::unique_ptr ret = std::unique_ptr(new Task(task->mode())); + std::unique_ptr ret = std::make_unique(task->mode()); for (auto&& c : task->_children) { auto child = simplify(std::move(c)); if (!child->empty()) { diff --git a/src/server/Task.hpp b/src/server/Task.hpp index b4e9848c..0a545655 100644 --- a/src/server/Task.hpp +++ b/src/server/Task.hpp @@ -90,7 +90,7 @@ public: /** Prepend a child to this task. */ void push_front(Task&& task) { - _children.emplace_front(std::unique_ptr(new Task(std::move(task)))); + _children.emplace_front(std::make_unique(std::move(task))); } Mode mode() const { return _mode; } diff --git a/tests/ingen_bench.cpp b/tests/ingen_bench.cpp index 2af53f89..07a59f9b 100644 --- a/tests/ingen_bench.cpp +++ b/tests/ingen_bench.cpp @@ -62,8 +62,7 @@ run(int argc, char** argv) { // Create world try { - world = std::unique_ptr{ - new ingen::World(nullptr, nullptr, nullptr)}; + world = std::make_unique(nullptr, nullptr, nullptr); world->conf().add( "output", "output", 'O', "File to write benchmark output", diff --git a/tests/ingen_test.cpp b/tests/ingen_test.cpp index 9f7da2f0..df7e9d34 100644 --- a/tests/ingen_test.cpp +++ b/tests/ingen_test.cpp @@ -78,7 +78,7 @@ run(int argc, char** argv) { // Create world try { - world = std::unique_ptr{new World(nullptr, nullptr, nullptr)}; + world = std::make_unique(nullptr, nullptr, nullptr); world->load_configuration(argc, argv); } catch (std::exception& e) { std::cout << "ingen: " << e.what() << std::endl; -- cgit v1.2.1