Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
authorMartin Hořeňovský2020-02-01 21:43:00 +0100
committerMartin Hořeňovský2020-02-01 23:34:00 +0100
commitea6db670632204bace889f646ca08bfa58bddeab (patch)
treee47f559036a91dd062ae6400f2612c398c6a9014 /examples
parenta7b3e087a03f6ba33100c842445f16757d545fc0 (diff)
downloadcatch3-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.cpp4
-rw-r--r--examples/301-Gen-MapTypeConversion.cpp4
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>()
);
}