diff --git a/examples/300-Gen-OwnGenerator.cpp b/examples/300-Gen-OwnGenerator.cpp index 427d7b24..0cb80c2f 100644 --- a/examples/300-Gen-OwnGenerator.cpp +++ b/examples/300-Gen-OwnGenerator.cpp @@ -40,7 +40,9 @@ int const& RandomIntGenerator::get() const { // Notice that it returns an instance of GeneratorWrapper, which // is a value-wrapper around std::unique_ptr>. Catch::Generators::GeneratorWrapper random(int low, int high) { - return Catch::Generators::GeneratorWrapper(std::unique_ptr>(new RandomIntGenerator(low, high))); + return Catch::Generators::GeneratorWrapper( + std::make_unique(low, high) + ); } // The two sections in this test case are equivalent, but the first one diff --git a/examples/301-Gen-MapTypeConversion.cpp b/examples/301-Gen-MapTypeConversion.cpp index dee50822..66f582d6 100644 --- a/examples/301-Gen-MapTypeConversion.cpp +++ b/examples/301-Gen-MapTypeConversion.cpp @@ -38,9 +38,7 @@ std::string const& LineGenerator::get() const { // is a value-wrapper around std::unique_ptr>. Catch::Generators::GeneratorWrapper lines(std::string /* ignored for example */) { return Catch::Generators::GeneratorWrapper( - std::unique_ptr>( - new LineGenerator() - ) + std::make_unique() ); } diff --git a/src/catch2/catch_enum_values_registry.cpp b/src/catch2/catch_enum_values_registry.cpp index f7d11860..79261bcf 100644 --- a/src/catch2/catch_enum_values_registry.cpp +++ b/src/catch2/catch_enum_values_registry.cpp @@ -52,7 +52,7 @@ namespace Catch { } std::unique_ptr makeEnumInfo( StringRef enumName, StringRef allValueNames, std::vector const& values ) { - std::unique_ptr enumInfo( new EnumInfo ); + auto enumInfo = std::make_unique(); enumInfo->m_name = enumName; enumInfo->m_values.reserve( values.size() ); diff --git a/src/catch2/catch_generators.hpp b/src/catch2/catch_generators.hpp index 3756a719..359db5f4 100644 --- a/src/catch2/catch_generators.hpp +++ b/src/catch2/catch_generators.hpp @@ -33,14 +33,6 @@ public: namespace Generators { - // !TBD move this into its own location? - namespace pf{ - template - std::unique_ptr make_unique( Args&&... args ) { - return std::unique_ptr(new T(std::forward(args)...)); - } - } - template struct IGenerator : GeneratorUntypedBase { virtual ~IGenerator() = default; @@ -104,11 +96,11 @@ namespace Generators { template GeneratorWrapper value(T&& value) { - return GeneratorWrapper(pf::make_unique>(std::forward(value))); + return GeneratorWrapper(std::make_unique>(std::forward(value))); } template GeneratorWrapper values(std::initializer_list values) { - return GeneratorWrapper(pf::make_unique>(values)); + return GeneratorWrapper(std::make_unique>(values)); } template @@ -193,7 +185,7 @@ namespace Generators { IGeneratorTracker& tracker = acquireGeneratorTracker( lineInfo ); if (!tracker.hasGenerator()) { - tracker.setGenerator(pf::make_unique>(generatorExpression())); + tracker.setGenerator(std::make_unique>(generatorExpression())); } auto const& generator = static_cast const&>( *tracker.getGenerator() ); diff --git a/src/catch2/catch_generators_generic.hpp b/src/catch2/catch_generators_generic.hpp index 3cfa9202..5a8708dc 100644 --- a/src/catch2/catch_generators_generic.hpp +++ b/src/catch2/catch_generators_generic.hpp @@ -46,7 +46,7 @@ namespace Generators { template GeneratorWrapper take(size_t target, GeneratorWrapper&& generator) { - return GeneratorWrapper(pf::make_unique>(target, std::move(generator))); + return GeneratorWrapper(std::make_unique>(target, std::move(generator))); } @@ -87,7 +87,7 @@ namespace Generators { template GeneratorWrapper filter(Predicate&& pred, GeneratorWrapper&& generator) { - return GeneratorWrapper(std::unique_ptr>(pf::make_unique>(std::forward(pred), std::move(generator)))); + return GeneratorWrapper(std::unique_ptr>(std::make_unique>(std::forward(pred), std::move(generator)))); } template @@ -143,7 +143,7 @@ namespace Generators { template GeneratorWrapper repeat(size_t repeats, GeneratorWrapper&& generator) { - return GeneratorWrapper(pf::make_unique>(repeats, std::move(generator))); + return GeneratorWrapper(std::make_unique>(repeats, std::move(generator))); } template @@ -176,14 +176,14 @@ namespace Generators { template > GeneratorWrapper map(Func&& function, GeneratorWrapper&& generator) { return GeneratorWrapper( - pf::make_unique>(std::forward(function), std::move(generator)) + std::make_unique>(std::forward(function), std::move(generator)) ); } template GeneratorWrapper map(Func&& function, GeneratorWrapper&& generator) { return GeneratorWrapper( - pf::make_unique>(std::forward(function), std::move(generator)) + std::make_unique>(std::forward(function), std::move(generator)) ); } @@ -226,7 +226,7 @@ namespace Generators { template GeneratorWrapper> chunk(size_t size, GeneratorWrapper&& generator) { return GeneratorWrapper>( - pf::make_unique>(size, std::move(generator)) + std::make_unique>(size, std::move(generator)) ); } diff --git a/src/catch2/catch_generators_specific.hpp b/src/catch2/catch_generators_specific.hpp index 0e497c3e..acca7d97 100644 --- a/src/catch2/catch_generators_specific.hpp +++ b/src/catch2/catch_generators_specific.hpp @@ -68,7 +68,7 @@ typename std::enable_if::value && !std::is_same::va GeneratorWrapper>::type random(T a, T b) { return GeneratorWrapper( - pf::make_unique>(a, b) + std::make_unique>(a, b) ); } @@ -77,7 +77,7 @@ typename std::enable_if::value, GeneratorWrapper>::type random(T a, T b) { return GeneratorWrapper( - pf::make_unique>(a, b) + std::make_unique>(a, b) ); } @@ -118,13 +118,13 @@ public: template GeneratorWrapper range(T const& start, T const& end, T const& step) { static_assert(std::is_arithmetic::value && !std::is_same::value, "Type must be numeric"); - return GeneratorWrapper(pf::make_unique>(start, end, step)); + return GeneratorWrapper(std::make_unique>(start, end, step)); } template GeneratorWrapper range(T const& start, T const& end) { static_assert(std::is_integral::value && !std::is_same::value, "Type must be an integer"); - return GeneratorWrapper(pf::make_unique>(start, end)); + return GeneratorWrapper(std::make_unique>(start, end)); } @@ -158,13 +158,13 @@ template ::value_type> GeneratorWrapper from_range(InputIterator from, InputSentinel to) { - return GeneratorWrapper(pf::make_unique>(from, to)); + return GeneratorWrapper(std::make_unique>(from, to)); } template GeneratorWrapper from_range(Container const& cnt) { - return GeneratorWrapper(pf::make_unique>(cnt.begin(), cnt.end())); + return GeneratorWrapper(std::make_unique>(cnt.begin(), cnt.end())); } diff --git a/src/catch2/catch_reporter_registrars.hpp b/src/catch2/catch_reporter_registrars.hpp index cbc4fb73..4aecd518 100644 --- a/src/catch2/catch_reporter_registrars.hpp +++ b/src/catch2/catch_reporter_registrars.hpp @@ -40,7 +40,7 @@ namespace Catch { class ListenerFactory : public IReporterFactory { IStreamingReporterPtr create( ReporterConfig const& config ) const override { - return std::unique_ptr( new T( config ) ); + return std::make_unique(config); } std::string getDescription() const override { return std::string(); diff --git a/src/catch2/catch_stream.cpp b/src/catch2/catch_stream.cpp index 6c8e2828..23a43001 100644 --- a/src/catch2/catch_stream.cpp +++ b/src/catch2/catch_stream.cpp @@ -108,7 +108,7 @@ namespace Catch { mutable std::ostream m_os; public: DebugOutStream() - : m_streamBuf( new StreamBufImpl() ), + : m_streamBuf( std::make_unique>() ), m_os( m_streamBuf.get() ) {}