diff options
| author | Martin Hořeňovský | 2020-02-01 21:43:00 +0100 |
|---|---|---|
| committer | Martin Hořeňovský | 2020-02-01 23:34:00 +0100 |
| commit | ea6db670632204bace889f646ca08bfa58bddeab (patch) | |
| tree | e47f559036a91dd062ae6400f2612c398c6a9014 /examples | |
| parent | a7b3e087a03f6ba33100c842445f16757d545fc0 (diff) | |
| download | catch3-ea6db670632204bace889f646ca08bfa58bddeab.tar.gz | |
Use std::make_unique instead of our polyfill or naked new
The use we previously used the polyfill or naked new is that we
supported C++11, which did not yet have `std::make_unique`. However,
with the move to C++14 as the minimum, `std::make_unique` can be
expected to be always available.
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/300-Gen-OwnGenerator.cpp | 4 | ||||
| -rw-r--r-- | examples/301-Gen-MapTypeConversion.cpp | 4 |
2 files changed, 4 insertions, 4 deletions
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<int>, which // is a value-wrapper around std::unique_ptr<IGenerator<int>>. Catch::Generators::GeneratorWrapper<int> random(int low, int high) { - return Catch::Generators::GeneratorWrapper<int>(std::unique_ptr<Catch::Generators::IGenerator<int>>(new RandomIntGenerator(low, high))); + return Catch::Generators::GeneratorWrapper<int>( + std::make_unique<RandomIntGenerator>(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<IGenerator<std::string>>. Catch::Generators::GeneratorWrapper<std::string> lines(std::string /* ignored for example */) { return Catch::Generators::GeneratorWrapper<std::string>( - std::unique_ptr<Catch::Generators::IGenerator<std::string>>( - new LineGenerator() - ) + std::make_unique<LineGenerator>() ); } |