Use Detail::make_unique<T> in more places

This commit is contained in:
Martin Hořeňovský 2021-08-10 00:16:05 +02:00
parent 3ec63324a8
commit 3579c055c8
No known key found for this signature in database
GPG Key ID: DE48307B8B0D381A
3 changed files with 6 additions and 12 deletions

View File

@ -43,19 +43,13 @@ namespace Catch {
return createReporter(config->getReporterName(), config);
}
// On older platforms, returning unique_ptr<ListeningReporter>
// when the return type is unique_ptr<IStreamingReporter>
// doesn't compile without a std::move call. However, this causes
// a warning on newer platforms. Thus, we have to work around
// it a bit and downcast the pointer manually.
auto ret = Detail::unique_ptr<IStreamingReporter>(new ListeningReporter(config));
auto& multi = static_cast<ListeningReporter&>(*ret);
auto multi = Detail::make_unique<ListeningReporter>(config);
auto const& listeners = Catch::getRegistryHub().getReporterRegistry().getListeners();
for (auto const& listener : listeners) {
multi.addListener(listener->create(Catch::ReporterConfig(config)));
multi->addListener(listener->create(Catch::ReporterConfig(config)));
}
multi.addReporter(createReporter(config->getReporterName(), config));
return ret;
multi->addReporter(createReporter(config->getReporterName(), config));
return multi;
}
class TestGroup {

View File

@ -107,7 +107,7 @@ namespace Catch {
makeTestCaseInfo(std::string const& _className,
NameAndTags const& nameAndTags,
SourceLineInfo const& _lineInfo ) {
return Detail::unique_ptr<TestCaseInfo>(new TestCaseInfo(_className, nameAndTags, _lineInfo));
return Detail::make_unique<TestCaseInfo>(_className, nameAndTags, _lineInfo);
}
TestCaseInfo::TestCaseInfo(std::string const& _className,

View File

@ -145,7 +145,7 @@ namespace Detail {
auto add() -> std::size_t {
if( m_unused.empty() ) {
m_streams.push_back( Detail::unique_ptr<std::ostringstream>( new std::ostringstream ) );
m_streams.push_back( Detail::make_unique<std::ostringstream>() );
return m_streams.size()-1;
}
else {