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.
This commit is contained in:
Martin Hořeňovský
2020-02-01 23:34:00 +01:00
parent a7b3e087a0
commit ea6db67063
8 changed files with 22 additions and 30 deletions
+3 -11
View File
@@ -33,14 +33,6 @@ public:
namespace Generators {
// !TBD move this into its own location?
namespace pf{
template<typename T, typename... Args>
std::unique_ptr<T> make_unique( Args&&... args ) {
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
}
}
template<typename T>
struct IGenerator : GeneratorUntypedBase {
virtual ~IGenerator() = default;
@@ -104,11 +96,11 @@ namespace Generators {
template <typename T>
GeneratorWrapper<T> value(T&& value) {
return GeneratorWrapper<T>(pf::make_unique<SingleValueGenerator<T>>(std::forward<T>(value)));
return GeneratorWrapper<T>(std::make_unique<SingleValueGenerator<T>>(std::forward<T>(value)));
}
template <typename T>
GeneratorWrapper<T> values(std::initializer_list<T> values) {
return GeneratorWrapper<T>(pf::make_unique<FixedValuesGenerator<T>>(values));
return GeneratorWrapper<T>(std::make_unique<FixedValuesGenerator<T>>(values));
}
template<typename T>
@@ -193,7 +185,7 @@ namespace Generators {
IGeneratorTracker& tracker = acquireGeneratorTracker( lineInfo );
if (!tracker.hasGenerator()) {
tracker.setGenerator(pf::make_unique<Generators<UnderlyingType>>(generatorExpression()));
tracker.setGenerator(std::make_unique<Generators<UnderlyingType>>(generatorExpression()));
}
auto const& generator = static_cast<IGenerator<UnderlyingType> const&>( *tracker.getGenerator() );