clang-tidy: modernize make-unique/shared
authorRoland Schulz <roland.schulz@intel.com>
Tue, 17 Jul 2018 20:27:44 +0000 (13:27 -0700)
committerMark Abraham <mark.j.abraham@gmail.com>
Sat, 4 Aug 2018 22:04:56 +0000 (00:04 +0200)
Change-Id: I913646526c767a409b74854c3a8efce5806a2a97

21 files changed:
src/.clang-tidy [new file with mode: 0644]
src/gromacs/CMakeLists.txt
src/gromacs/analysisdata/datastorage.cpp
src/gromacs/awh/bias.cpp
src/gromacs/commandline/cmdlinehelpmodule.cpp
src/gromacs/commandline/cmdlineinit.cpp
src/gromacs/commandline/shellcompletions.cpp
src/gromacs/essentialdynamics/edsam.cpp
src/gromacs/fileio/checkpoint.cpp
src/gromacs/gmxana/gmx_awh.cpp
src/gromacs/mdlib/forcerec.cpp
src/gromacs/mdlib/mdebin_bar.cpp
src/gromacs/mdrun/md.cpp
src/gromacs/mdrun/runner.cpp
src/gromacs/mdrunutility/mdmodules.cpp
src/gromacs/onlinehelp/helpwritercontext.cpp
src/gromacs/options/options.cpp
src/gromacs/selection/parsetree.cpp
src/gromacs/selection/selectioncollection.cpp
src/gromacs/swap/swapcoords.cpp
src/gromacs/utility/keyvaluetreetransform.cpp

diff --git a/src/.clang-tidy b/src/.clang-tidy
new file mode 100644 (file)
index 0000000..f70b77d
--- /dev/null
@@ -0,0 +1,9 @@
+CheckOptions:
+  - key:           modernize-make-unique.MakeSmartPtrFunction
+    value:         gmx::compat::make_unique
+  - key:           modernize-make-unique.MakeSmartPtrFunctionHeader
+    value:         gromacs/compat/make_unique.h
+  - key:           modernize-make-unique.IncludeStyle
+    value:         google
+  - key:           modernize-make-shared.IncludeStyle
+    value:         google
index beeddfeaa058389f1a3ceab2c9644430258209cb..ec2876c840389f5fd49974c0e1eeb533cf204bd1 100644 (file)
@@ -345,6 +345,7 @@ if (GMX_CLANG_TIDY)
        "-readability-inconsistent-declaration-parameter-name"
        "-readability-implicit-bool-conversion" #TODO: Remove gmx_bool
        "modernize-use-nullptr" "modernize-use-emplace"
+       "modernize-make-unique" "modernize-make-shared"
        )
    string(REPLACE ";" "," CLANG_TIDY_CHECKS "${CLANG_TIDY_CHECKS}")
    set_target_properties(libgromacs PROPERTIES CXX_CLANG_TIDY
index d70f095258d64576e5e8ff0a678a0e80acd79876..164f9b877d0d74e0f6e034805157142b7fea67be 100644 (file)
@@ -53,6 +53,7 @@
 #include "gromacs/analysisdata/dataframe.h"
 #include "gromacs/analysisdata/datamodulemanager.h"
 #include "gromacs/analysisdata/paralleloptions.h"
+#include "gromacs/compat/make_unique.h"
 #include "gromacs/utility/exceptions.h"
 #include "gromacs/utility/gmxassert.h"
 
@@ -450,7 +451,7 @@ AnalysisDataStorageImpl::extendBuffer(size_t newSize)
     frames_.reserve(newSize);
     while (frames_.size() < newSize)
     {
-        frames_.push_back(FramePointer(new AnalysisDataStorageFrameData(this, nextIndex_)));
+        frames_.push_back(compat::make_unique<AnalysisDataStorageFrameData>(this, nextIndex_));
         ++nextIndex_;
     }
     // The unused frame should not be included in the count.
index 4310aef885eb6350457e1bd414e516d55f95a7a4..14f4bc770c6d13d52db0050f6e001c412bb9d112 100644 (file)
@@ -55,6 +55,7 @@
 
 #include <algorithm>
 
+#include "gromacs/compat/make_unique.h"
 #include "gromacs/fileio/gmxfio.h"
 #include "gromacs/gmxlib/network.h"
 #include "gromacs/math/utilities.h"
@@ -349,11 +350,11 @@ Bias::Bias(int                             biasIndexInCollection,
         double blockLength = 0;
         /* Construct the force correlation object. */
         forceCorrelationGrid_ =
-            gmx::compat::make_unique<CorrelationGrid>(state_.points().size(), ndim(),
-                                                      blockLength, CorrelationGrid::BlockLengthMeasure::Time,
-                                                      awhParams.nstSampleCoord*mdTimeStep);
+            compat::make_unique<CorrelationGrid>(state_.points().size(), ndim(),
+                                                 blockLength, CorrelationGrid::BlockLengthMeasure::Time,
+                                                 awhParams.nstSampleCoord*mdTimeStep);
 
-        writer_ = std::unique_ptr<BiasWriter>(new BiasWriter(*this));
+        writer_ = compat::make_unique<BiasWriter>(*this);
     }
 }
 
index dba1408a969c74ef316816ee9aaaaba01b29582f..cf006c3908edccae6ba7d02c003b9e9fc60c2c03 100644 (file)
@@ -50,6 +50,7 @@
 #include "gromacs/commandline/cmdlinehelpcontext.h"
 #include "gromacs/commandline/cmdlinehelpwriter.h"
 #include "gromacs/commandline/cmdlineparser.h"
+#include "gromacs/compat/make_unique.h"
 #include "gromacs/onlinehelp/helpformat.h"
 #include "gromacs/onlinehelp/helpmanager.h"
 #include "gromacs/onlinehelp/helptopic.h"
@@ -567,15 +568,13 @@ HelpExportReStructuredText::HelpExportReStructuredText(
 
 void HelpExportReStructuredText::startModuleExport()
 {
-    indexFile_.reset(
-            new TextWriter(
-                    outputRedirector_->openTextOutputFile("fragments/byname.rst")));
+    indexFile_ = compat::make_unique<TextWriter>(
+                outputRedirector_->openTextOutputFile("fragments/byname.rst"));
     indexFile_->writeLine(formatString("* :doc:`%s </onlinehelp/%s>` - %s",
                                        binaryName_.c_str(), binaryName_.c_str(),
                                        RootHelpText::title));
-    manPagesFile_.reset(
-            new TextWriter(
-                    outputRedirector_->openTextOutputFile("conf-man.py")));
+    manPagesFile_ = compat::make_unique<TextWriter>(
+                outputRedirector_->openTextOutputFile("conf-man.py"));
     manPagesFile_->writeLine("man_pages = [");
 }
 
@@ -636,12 +635,10 @@ void HelpExportReStructuredText::finishModuleExport()
 
 void HelpExportReStructuredText::startModuleGroupExport()
 {
-    indexFile_.reset(
-            new TextWriter(
-                    outputRedirector_->openTextOutputFile("fragments/bytopic.rst")));
-    manPagesFile_.reset(
-            new TextWriter(
-                    outputRedirector_->openTextOutputFile("fragments/bytopic-man.rst")));
+    indexFile_ = compat::make_unique<TextWriter>(
+                outputRedirector_->openTextOutputFile("fragments/bytopic.rst"));
+    manPagesFile_ = compat::make_unique<TextWriter>(
+                outputRedirector_->openTextOutputFile("fragments/bytopic-man.rst"));
 }
 
 void HelpExportReStructuredText::exportModuleGroup(
index 0420c4cb47b67f75c02bb8afb846b7c0af78a200..a9561e08c201816e1e73d51fe779ddb3c3078873 100644 (file)
@@ -51,6 +51,7 @@
 #include "gromacs/commandline/cmdlinemodulemanager.h"
 #include "gromacs/commandline/cmdlineoptionsmodule.h"
 #include "gromacs/commandline/cmdlineprogramcontext.h"
+#include "gromacs/compat/make_unique.h"
 #include "gromacs/utility/basenetwork.h"
 #include "gromacs/utility/datafilefinder.h"
 #include "gromacs/utility/exceptions.h"
@@ -125,9 +126,9 @@ CommandLineProgramContext &initForCommandLine(int *argc, char ***argv)
     broadcastArguments(argc, argv);
     try
     {
-        g_commandLineContext.reset(new CommandLineProgramContext(*argc, *argv));
+        g_commandLineContext = compat::make_unique<CommandLineProgramContext>(*argc, *argv);
         setProgramContext(g_commandLineContext.get());
-        g_libFileFinder.reset(new DataFileFinder());
+        g_libFileFinder = compat::make_unique<DataFileFinder>();
         g_libFileFinder->setSearchPathFromEnv("GMXLIB");
         setLibraryFileFinder(g_libFileFinder.get());
     }
index 7a8e23da57cf34f292de98b1744e40c555ea4575..9ecb1a930c728f2f415f2589c90c80a243ba40ad 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016,2017,2018, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -53,6 +53,7 @@
 
 #include "gromacs/commandline/cmdlinehelpcontext.h"
 #include "gromacs/commandline/pargs.h"
+#include "gromacs/compat/make_unique.h"
 #include "gromacs/fileio/filetypes.h"
 #include "gromacs/options/basicoptions.h"
 #include "gromacs/options/filenameoption.h"
@@ -221,7 +222,7 @@ TextWriter &ShellCompletionWriter::outputWriter()
 
 void ShellCompletionWriter::startCompletions()
 {
-    impl_->file_.reset(new TextWriter(impl_->binaryName_ + "-completion.bash"));
+    impl_->file_ = compat::make_unique<TextWriter>(impl_->binaryName_ + "-completion.bash");
 }
 
 void ShellCompletionWriter::writeModuleCompletions(
index 41febe0a6d566d977d982bd0b35f760a2f62f709..1549b0fdbfeb7f7e88cb3a27c5a8223e58e60686 100644 (file)
@@ -45,6 +45,7 @@
 #include <cmath>
 
 #include "gromacs/commandline/filenm.h"
+#include "gromacs/compat/make_unique.h"
 #include "gromacs/domdec/domdec_struct.h"
 #include "gromacs/fileio/gmxfio.h"
 #include "gromacs/fileio/xvgr.h"
@@ -1128,7 +1129,7 @@ static gmx_edsam_t ed_open(
         // If we start from a checkpoint file, we already have an edsamHistory struct
         if (oh->edsamHistory == nullptr)
         {
-            oh->edsamHistory = std::unique_ptr<edsamhistory_t>(new edsamhistory_t {});
+            oh->edsamHistory = gmx::compat::make_unique<edsamhistory_t>(edsamhistory_t {});
         }
         edsamhistory_t *EDstate = oh->edsamHistory.get();
 
index 8cb2c578915e844d6c831850ed1465861d3373f1..23181f40b5600bcd9e518a4143afad5418c96c8b 100644 (file)
 #endif
 
 #include <array>
+#include <memory>
 
 #include "buildinfo.h"
+#include "gromacs/compat/make_unique.h"
 #include "gromacs/fileio/filetypes.h"
 #include "gromacs/fileio/gmxfio.h"
 #include "gromacs/fileio/gmxfio-xdr.h"
@@ -1367,7 +1369,7 @@ static int do_cpt_enerhist(XDR *xd, gmx_bool bRead,
                     {
                         if (deltaH == nullptr)
                         {
-                            enerhist->deltaHForeignLambdas.reset(new delta_h_history_t);
+                            enerhist->deltaHForeignLambdas = gmx::compat::make_unique<delta_h_history_t>();
                             deltaH = enerhist->deltaHForeignLambdas.get();
                         }
                         deltaH->dh.resize(numDeltaH);
@@ -1646,7 +1648,7 @@ static int do_cpt_awh(XDR *xd, gmx_bool bRead,
         {
             GMX_RELEASE_ASSERT(bRead, "do_cpt_awh should not be called for writing without an AwhHistory");
 
-            awhHistoryLocal = std::shared_ptr<gmx::AwhHistory>(new gmx::AwhHistory());
+            awhHistoryLocal = std::make_shared<gmx::AwhHistory>();
             awhHistory      = awhHistoryLocal.get();
         }
 
@@ -2268,7 +2270,7 @@ static void read_checkpoint(const char *fn, FILE **pfplog,
 
     if (headerContents->flags_enh && observablesHistory->energyHistory == nullptr)
     {
-        observablesHistory->energyHistory = std::unique_ptr<energyhistory_t>(new energyhistory_t {});
+        observablesHistory->energyHistory = gmx::compat::make_unique<energyhistory_t>();
     }
     ret = do_cpt_enerhist(gmx_fio_getxdr(fp), TRUE,
                           headerContents->flags_enh, observablesHistory->energyHistory.get(), nullptr);
@@ -2290,7 +2292,7 @@ static void read_checkpoint(const char *fn, FILE **pfplog,
 
     if (headerContents->nED > 0 && observablesHistory->edsamHistory == nullptr)
     {
-        observablesHistory->edsamHistory = std::unique_ptr<edsamhistory_t>(new edsamhistory_t {});
+        observablesHistory->edsamHistory = gmx::compat::make_unique<edsamhistory_t>(edsamhistory_t {});
     }
     ret = do_cpt_EDstate(gmx_fio_getxdr(fp), TRUE, headerContents->nED, observablesHistory->edsamHistory.get(), nullptr);
     if (ret)
@@ -2300,7 +2302,7 @@ static void read_checkpoint(const char *fn, FILE **pfplog,
 
     if (headerContents->flags_awhh != 0 && state->awhHistory == nullptr)
     {
-        state->awhHistory = std::shared_ptr<gmx::AwhHistory>(new gmx::AwhHistory());
+        state->awhHistory = std::make_shared<gmx::AwhHistory>();
     }
     ret = do_cpt_awh(gmx_fio_getxdr(fp), TRUE,
                      headerContents->flags_awhh, state->awhHistory.get(), nullptr);
@@ -2311,7 +2313,7 @@ static void read_checkpoint(const char *fn, FILE **pfplog,
 
     if (headerContents->eSwapCoords != eswapNO && observablesHistory->swapHistory == nullptr)
     {
-        observablesHistory->swapHistory = std::unique_ptr<swaphistory_t>(new swaphistory_t {});
+        observablesHistory->swapHistory = gmx::compat::make_unique<swaphistory_t>(swaphistory_t {});
     }
     ret = do_cpt_swapstate(gmx_fio_getxdr(fp), TRUE, headerContents->eSwapCoords, observablesHistory->swapHistory.get(), nullptr);
     if (ret)
index f04f00b36e8bcbafe01a9636ecf3aa597ed6b73e..9b0f14d39752b293f442c4d6d3c3e158ee58e70f 100644 (file)
@@ -641,11 +641,11 @@ int gmx_awh(int argc, char *argv[])
                 AwhGraphSelection awhGraphSelection = (moreGraphs ? AwhGraphSelection::All : AwhGraphSelection::Pmf);
                 EnergyUnit        energyUnit        = (kTUnit ? EnergyUnit::KT : EnergyUnit::KJPerMol);
                 awhReader =
-                    std::unique_ptr<AwhReader>(new AwhReader(ir.awhParams,
-                                                             nfile, fnm,
-                                                             awhGraphSelection,
-                                                             energyUnit, BOLTZ*ir.opts.ref_t[0],
-                                                             block));
+                    gmx::compat::make_unique<AwhReader>(ir.awhParams,
+                                                        nfile, fnm,
+                                                        awhGraphSelection,
+                                                        energyUnit, BOLTZ*ir.opts.ref_t[0],
+                                                        block);
             }
 
             awhReader->processAwhFrame(*block, frame->t, oenv);
index b7bcdb28d00dad81873fd201f6242264e1446481..329a73feb45900a0aefbd859d4c54aed3f91d6bf 100644 (file)
@@ -2187,7 +2187,7 @@ static void init_nb_verlet(const gmx::MDLogger     &mdlog,
         }
     }
 
-    nbv->listParams = std::unique_ptr<NbnxnListParameters>(new NbnxnListParameters(ir->rlist));
+    nbv->listParams = gmx::compat::make_unique<NbnxnListParameters>(ir->rlist);
     setupDynamicPairlistPruning(mdlog, ir, mtop, box, nbv->grp[0].kernel_type, fr->ic,
                                 nbv->listParams.get());
 
index c1c359ac54a9b094cc1e722e94c97ee0e4fa0cd8..58d77cbc52271d837531db95eb7d82bee4464962 100644 (file)
@@ -44,6 +44,7 @@
 #include <cassert>
 #include <cmath>
 
+#include "gromacs/compat/make_unique.h"
 #include "gromacs/fileio/enxio.h"
 #include "gromacs/mdlib/mdebin.h"
 #include "gromacs/mdtypes/energyhistory.h"
@@ -716,7 +717,7 @@ void mde_delta_h_coll_update_energyhistory(const t_mde_delta_h_coll *dhc,
 {
     if (enerhist->deltaHForeignLambdas == nullptr)
     {
-        enerhist->deltaHForeignLambdas.reset(new delta_h_history_t);
+        enerhist->deltaHForeignLambdas = gmx::compat::make_unique<delta_h_history_t>();
         enerhist->deltaHForeignLambdas->dh.resize(dhc->ndh);
     }
 
index 1b0f144e66d19fe393656c95dc9c038d963819d9..e7040165f027cc7654b6e8d8f143e993e255dd2a 100644 (file)
@@ -462,7 +462,7 @@ void gmx::Integrator::do_md()
     {
         top = dd_init_local_top(top_global);
 
-        stateInstance = gmx::compat::make_unique<t_state>();
+        stateInstance = compat::make_unique<t_state>();
         state         = stateInstance.get();
         dd_init_local_state(cr->dd, state_global, state);
 
@@ -529,7 +529,7 @@ void gmx::Integrator::do_md()
         }
         if (observablesHistory->energyHistory == nullptr)
         {
-            observablesHistory->energyHistory = std::unique_ptr<energyhistory_t>(new energyhistory_t {});
+            observablesHistory->energyHistory = compat::make_unique<energyhistory_t>();
         }
         /* Set the initial energy history in state by updating once */
         update_energyhistory(observablesHistory->energyHistory.get(), mdebin);
index 672a93368c0def2232ab8c0bf5be428ad2aaa2ed..4c7a2dead43f0063b33114f6646578ed4ec022b8 100644 (file)
@@ -55,6 +55,7 @@
 #include <algorithm>
 
 #include "gromacs/commandline/filenm.h"
+#include "gromacs/compat/make_unique.h"
 #include "gromacs/domdec/domdec.h"
 #include "gromacs/domdec/domdec_struct.h"
 #include "gromacs/domdec/localatomsetmanager.h"
@@ -505,7 +506,7 @@ int Mdrunner::mdrunner()
     if (SIMMASTER(cr))
     {
         /* Only the master rank has the global state */
-        globalState = std::unique_ptr<t_state>(new t_state);
+        globalState = compat::make_unique<t_state>();
 
         /* Read (nearly) all data required for the simulation */
         read_tpx_state(ftp2fn(efTPR, nfile, fnm), inputrec, globalState.get(), &mtop);
@@ -663,7 +664,7 @@ int Mdrunner::mdrunner()
     {
         if (!MASTER(cr))
         {
-            globalState = std::unique_ptr<t_state>(new t_state);
+            globalState = compat::make_unique<t_state>();
         }
         broadcastStateWithoutDynamics(cr, globalState.get());
     }
index 2ee50c8928047a6021bcae1d4601a3ac9a6c82f0..62de105da3bcd378cad7f7e31d93231011e7feeb 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2016,2017,2018, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -39,6 +39,7 @@
 #include <memory>
 
 #include "gromacs/applied-forces/electricfield.h"
+#include "gromacs/compat/make_unique.h"
 #include "gromacs/mdtypes/iforceprovider.h"
 #include "gromacs/mdtypes/imdmodule.h"
 #include "gromacs/mdtypes/imdoutputprovider.h"
@@ -139,7 +140,7 @@ ForceProviders *MDModules::initForceProviders()
 {
     GMX_RELEASE_ASSERT(impl_->forceProviders_ == nullptr,
                        "Force providers initialized multiple times");
-    impl_->forceProviders_.reset(new ForceProviders);
+    impl_->forceProviders_ = compat::make_unique<ForceProviders>();
     impl_->field_->initForceProviders(impl_->forceProviders_.get());
     return impl_->forceProviders_.get();
 }
index dcc655e3d23ba025f660ed2630443ded26e13170..61bc1b9168f862facb0452deff642c50414c1302 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2012,2013,2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2012,2013,2014,2015,2016,2017,2018, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -50,6 +50,7 @@
 #include <string>
 #include <vector>
 
+#include "gromacs/compat/make_unique.h"
 #include "gromacs/onlinehelp/helpformat.h"
 #include "gromacs/utility/exceptions.h"
 #include "gromacs/utility/gmxassert.h"
@@ -455,7 +456,7 @@ class HelpWriterContext::Impl
                                        "Accessing console formatter for non-console output");
                     if (!consoleOptionsFormatter_)
                     {
-                        consoleOptionsFormatter_.reset(new TextTableFormatter());
+                        consoleOptionsFormatter_ = compat::make_unique<TextTableFormatter>();
                         consoleOptionsFormatter_->setFirstColumnIndent(1);
                         consoleOptionsFormatter_->addColumn(nullptr, 7, false);
                         consoleOptionsFormatter_->addColumn(nullptr, 18, false);
index f063820c227809a126af59588c3aa738c2580bd3..9f9486aeea064091a37c573b411483a74c498cc8 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2010,2011,2012,2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2010,2011,2012,2014,2015,2016,2017,2018, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -45,6 +45,7 @@
 
 #include <utility>
 
+#include "gromacs/compat/make_unique.h"
 #include "gromacs/options/abstractoption.h"
 #include "gromacs/options/abstractoptionstorage.h"
 #include "gromacs/options/optionsection.h"
@@ -113,7 +114,7 @@ OptionSectionImpl::addSectionImpl(const AbstractOptionSection &section)
     // Make sure that there are no duplicate sections.
     GMX_RELEASE_ASSERT(findSection(name) == nullptr, "Duplicate subsection name");
     std::unique_ptr<IOptionSectionStorage> storage(section.createStorage());
-    subsections_.push_back(SectionPointer(new OptionSectionImpl(managers_, std::move(storage), name)));
+    subsections_.push_back(compat::make_unique<OptionSectionImpl>(managers_, std::move(storage), name));
     return subsections_.back().get();
 }
 
index 2db9ae10357534a85ee32776ff65e88824d4a23f..9ec275098983a6612430b2706fc5e14b84e9fd4b 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2009,2010,2011,2012,2013,2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2009,2010,2011,2012,2013,2014,2015,2016,2017,2018, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
 
 #include <exception>
 
+#include "gromacs/compat/make_unique.h"
 #include "gromacs/selection/selection.h"
 #include "gromacs/utility/cstringutil.h"
 #include "gromacs/utility/exceptions.h"
@@ -357,9 +358,9 @@ SelectionParserParameter::SelectionParserParameter(
         const char                      *name,
         SelectionParserValueListPointer  values,
         const SelectionLocation         &location)
-    : name_(name != nullptr ? name : ""), location_(location),
-      values_(values ? std::move(values)
-              : SelectionParserValueListPointer(new SelectionParserValueList))
+    : name_(name != nullptr ? name : ""),
+      location_(location),
+      values_(values ? std::move(values) : compat::make_unique<SelectionParserValueList>())
 {
 }
 
index 7b9b17073d9a99caad2e6f42c57d1343842f72d0..de4e8416aa106118afd5f7d4bd63b0248a3fea70 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2010,2011,2012,2013,2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2010,2011,2012,2013,2014,2015,2016,2017,2018, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -50,6 +50,7 @@
 #include <string>
 #include <vector>
 
+#include "gromacs/compat/make_unique.h"
 #include "gromacs/onlinehelp/helpmanager.h"
 #include "gromacs/onlinehelp/helpwritercontext.h"
 #include "gromacs/options/basicoptions.h"
@@ -91,7 +92,7 @@ SelectionCollection::Impl::Impl()
     sc_.top       = nullptr;
     gmx_ana_index_clear(&sc_.gall);
     sc_.mempool   = nullptr;
-    sc_.symtab.reset(new SelectionParserSymbolTable);
+    sc_.symtab    = compat::make_unique<SelectionParserSymbolTable>();
     gmx_ana_index_clear(&requiredAtoms_);
     gmx_ana_selmethod_register_defaults(sc_.symtab.get());
 }
@@ -725,7 +726,7 @@ std::unique_ptr<TextWriter> initStatusWriter(TextOutputStream *statusStream)
     std::unique_ptr<TextWriter> statusWriter;
     if (statusStream != nullptr)
     {
-        statusWriter.reset(new TextWriter(statusStream));
+        statusWriter = compat::make_unique<TextWriter>(statusStream);
         statusWriter->wrapperSettings().setLineLength(78);
     }
     return statusWriter;
index 2d579e4aec85cb17ad6ad7faeaeee3c251fbbb13..0c2ccd800e3c1182278060ee7a036c00c41be043 100644 (file)
@@ -49,6 +49,7 @@
 
 #include <string>
 
+#include "gromacs/compat/make_unique.h"
 #include "gromacs/domdec/domdec_struct.h"
 #include "gromacs/fileio/confio.h"
 #include "gromacs/fileio/gmxfio.h"
@@ -1555,7 +1556,7 @@ void init_swapcoords(
     {
         if (oh->swapHistory == nullptr)
         {
-            oh->swapHistory = std::unique_ptr<swaphistory_t>(new swaphistory_t {});
+            oh->swapHistory = gmx::compat::make_unique<swaphistory_t>(swaphistory_t {});
         }
         swapstate = oh->swapHistory.get();
 
index cf4f32f963985c85a54cee90bbe5bd1dda8c6e8e..7d138047b278cb62d670e710af4f3a0249785a5a 100644 (file)
@@ -42,6 +42,7 @@
 #include <typeindex>
 #include <vector>
 
+#include "gromacs/compat/make_unique.h"
 #include "gromacs/utility/exceptions.h"
 #include "gromacs/utility/ikeyvaluetreeerror.h"
 #include "gromacs/utility/keyvaluetreebuilder.h"
@@ -324,7 +325,7 @@ class KeyValueTreeTransformerImpl
         {
             GMX_RELEASE_ASSERT(rootRule_ == nullptr,
                                "Cannot specify key match type after child rules");
-            rootRule_.reset(new Rule(keyMatchType));
+            rootRule_ = compat::make_unique<Rule>(keyMatchType);
         }
 
         std::unique_ptr<Rule>             rootRule_;