From 2b557a42ffb7015e618a2badfc1d6c1fe49ced5e Mon Sep 17 00:00:00 2001 From: Markus Blatt Date: Tue, 18 Aug 2020 16:27:51 +0200 Subject: [PATCH] Make unique_ptr instantiation exception safe for the kids in readDeck. --- opm/simulators/utils/readDeck.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/opm/simulators/utils/readDeck.cpp b/opm/simulators/utils/readDeck.cpp index bed037bb2..25a53d761 100644 --- a/opm/simulators/utils/readDeck.cpp +++ b/opm/simulators/utils/readDeck.cpp @@ -186,7 +186,7 @@ void readDeck(int rank, std::string& deckFilename, std::unique_ptr& d if (!deck) { Opm::Parser parser; - deck.reset( new Opm::Deck( parser.parseFile(deckFilename , *parseContext, *errorGuard))); + deck = std::make_unique( parser.parseFile(deckFilename , *parseContext, *errorGuard)); Opm::MissingFeatures::checkKeywords(*deck, *parseContext, *errorGuard); if ( checkDeck ) Opm::checkDeck(*deck, parser, *parseContext, *errorGuard); @@ -194,9 +194,9 @@ void readDeck(int rank, std::string& deckFilename, std::unique_ptr& d if (!eclipseState) { #if HAVE_MPI - eclipseState.reset(new Opm::ParallelEclipseState(*deck)); + eclipseState = std::make_unique(*deck); #else - eclipseState.reset(new Opm::EclipseState(*deck)); + eclipseState = std::make_unique(*deck); #endif } /* @@ -211,15 +211,15 @@ void readDeck(int rank, std::string& deckFilename, std::unique_ptr& d Opm::EclIO::ERst rst_file(rst_filename); const auto& rst_state = Opm::RestartIO::RstState::load(rst_file, report_step); if (!schedule) - schedule.reset(new Opm::Schedule(*deck, *eclipseState, *parseContext, *errorGuard, python, &rst_state) ); + schedule = std::make_unique(*deck, *eclipseState, *parseContext, *errorGuard, python, &rst_state); } else { if (!schedule) - schedule.reset(new Opm::Schedule(*deck, *eclipseState, *parseContext, *errorGuard, python)); + schedule = std::make_unique(*deck, *eclipseState, *parseContext, *errorGuard, python); } setupMessageLimiter(schedule->getMessageLimits(), "STDOUT_LOGGER"); if (!summaryConfig) - summaryConfig.reset( new Opm::SummaryConfig(*deck, *schedule, eclipseState->getTableManager(), *parseContext, *errorGuard)); + summaryConfig = std::make_unique(*deck, *schedule, eclipseState->getTableManager(), *parseContext, *errorGuard); #if HAVE_MPI parseSuccess = 1; #endif @@ -232,11 +232,11 @@ void readDeck(int rank, std::string& deckFilename, std::unique_ptr& d #if HAVE_MPI else { if (!summaryConfig) - summaryConfig.reset(new Opm::SummaryConfig); + summaryConfig = std::make_unique(); if (!schedule) - schedule.reset(new Opm::Schedule(python)); + schedule = std::make_unique(python); if (!eclipseState) - eclipseState.reset(new Opm::ParallelEclipseState); + eclipseState = std::make_unique(); } auto comm = Dune::MPIHelper::getCollectiveCommunication();