From 61a2019ee0aa9a93646bd43c47ff9b11156d37a3 Mon Sep 17 00:00:00 2001 From: Axel Naumann <Axel.Naumann@cern.ch> Date: Thu, 29 Sep 2016 12:26:11 +0200 Subject: [PATCH] Replace uses of auto_ptr by unique_ptr in headers. This allows us to turn off -Wno-deprecated-declarations, to make R__DEPRECATED useful. --- core/macosx/inc/TMacOSXSystem.h | 8 +++----- graf2d/cocoa/inc/TGCocoa.h | 20 +++++++------------ graf3d/gl/inc/TGL5D.h | 16 ++++----------- graf3d/gl/inc/TGLHistPainter.h | 14 ++++--------- graf3d/gl/inc/TGLParametric.h | 16 ++++----------- graf3d/gl/inc/TGLTH3Composition.h | 2 +- math/mathcore/inc/Math/GoFTest.h | 10 +++------- math/mathcore/inc/Math/IntegratorMultiDim.h | 10 +++++----- .../inc/Math/MinimTransformVariable.h | 10 +++++----- math/mathcore/src/GoFTest.cxx | 14 ++++++------- math/unuran/inc/TUnuran.h | 2 +- math/unuran/src/TUnuran.cxx | 8 ++++---- 12 files changed, 47 insertions(+), 83 deletions(-) diff --git a/core/macosx/inc/TMacOSXSystem.h b/core/macosx/inc/TMacOSXSystem.h index d0f81577caf..5bc1e4858cf 100644 --- a/core/macosx/inc/TMacOSXSystem.h +++ b/core/macosx/inc/TMacOSXSystem.h @@ -13,11 +13,9 @@ #ifndef ROOT_TMacOSXSystem #define ROOT_TMacOSXSystem -#include <memory> - -#ifndef ROOT_TUnixSystem #include "TUnixSystem.h" -#endif + +#include <memory> //////////////////////////////////////////////////////////////////// // // @@ -58,7 +56,7 @@ private: void ProcessApplicationDefinedEvent(void *event); - std::auto_ptr<ROOT::MacOSX::Detail::MacOSXSystem> fPimpl; //! + std::unique_ptr<ROOT::MacOSX::Detail::MacOSXSystem> fPimpl; //! bool fCocoaInitialized; //! bool fFirstDispatch; //! diff --git a/graf2d/cocoa/inc/TGCocoa.h b/graf2d/cocoa/inc/TGCocoa.h index 4f17034cc06..0959c3af8bc 100644 --- a/graf2d/cocoa/inc/TGCocoa.h +++ b/graf2d/cocoa/inc/TGCocoa.h @@ -13,21 +13,15 @@ #ifndef ROOT_TGCocoa #define ROOT_TGCocoa -#include <utility> -#include <vector> -#include <memory> -#include <string> -#include <map> - -#ifndef ROOT_CocoaGuiTypes #include "CocoaGuiTypes.h" -#endif -#ifndef ROOT_TVirtualX #include "TVirtualX.h" -#endif -#ifndef ROOT_X11Atoms #include "X11Atoms.h" -#endif + +#include <map> +#include <memory> +#include <string> +#include <utility> +#include <vector> /// \defgroup cocoa Cocoa backend /// \brief Interface to MacOS native graphics system. @@ -447,7 +441,7 @@ protected: Drawable_t fSelectedDrawable; - std::auto_ptr<ROOT::MacOSX::Details::CocoaPrivate> fPimpl; //! + std::unique_ptr<ROOT::MacOSX::Details::CocoaPrivate> fPimpl; //! Int_t fCocoaDraw; EDrawMode fDrawMode; diff --git a/graf3d/gl/inc/TGL5D.h b/graf3d/gl/inc/TGL5D.h index b07e73a72d7..4a820fc4fc8 100644 --- a/graf3d/gl/inc/TGL5D.h +++ b/graf3d/gl/inc/TGL5D.h @@ -11,21 +11,13 @@ #ifndef ROOT_TGL5D #define ROOT_TGL5D -#include <memory> -#include <vector> - -#ifndef ROOT_TGLHistPainter #include "TGLHistPainter.h" -#endif -#ifndef ROOT_TGLUtil #include "TGLUtil.h" -#endif -#ifndef ROOT_TNamed #include "TNamed.h" -#endif -#ifndef ROOT_TAxis #include "TAxis.h" -#endif + +#include <memory> +#include <vector> class TGL5DPainter; class TTree; @@ -106,7 +98,7 @@ private: //V4 can have a string type. Bool_t fV4IsString; //Painter to visualize dataset. - std::auto_ptr<TGLHistPainter> fPainter; + std::unique_ptr<TGLHistPainter> fPainter; //Indices of points, selected for some iso-level. std::vector<UInt_t> fIndices; diff --git a/graf3d/gl/inc/TGLHistPainter.h b/graf3d/gl/inc/TGLHistPainter.h index d4c7a6b12ee..9e53ece29f6 100644 --- a/graf3d/gl/inc/TGLHistPainter.h +++ b/graf3d/gl/inc/TGLHistPainter.h @@ -12,17 +12,11 @@ #ifndef ROOT_TGLHistPainter #define ROOT_TGLHistPainter -#include <memory> - -#ifndef ROOT_TVirtualHistPainter #include "TVirtualHistPainter.h" -#endif -#ifndef ROOT_TGLPlotPainter #include "TGLPlotPainter.h" -#endif -#ifndef ROOT_TGLPlotCamera #include "TGLPlotCamera.h" -#endif + +#include <memory> /* TGLHistPainter is a proxy class. It inherits TVirtualHistPainter and @@ -47,9 +41,9 @@ class TGLHistPainter : public TVirtualHistPainter { private: //Dynamic type is THistPainter, no problems with simultaneous inheritance and membership //TGLHistPainter delegates unsupported options/calls to this object - std::auto_ptr<TVirtualHistPainter> fDefaultPainter; + std::unique_ptr<TVirtualHistPainter> fDefaultPainter; //This member can have different dynamic types: TGLLegoPainter, etc. - std::auto_ptr<TGLPlotPainter> fGLPainter; + std::unique_ptr<TGLPlotPainter> fGLPainter; TGLParametricEquation *fEq; TH1 *fHist; diff --git a/graf3d/gl/inc/TGLParametric.h b/graf3d/gl/inc/TGLParametric.h index 45291a29b84..ce96ea1afc8 100644 --- a/graf3d/gl/inc/TGLParametric.h +++ b/graf3d/gl/inc/TGLParametric.h @@ -12,20 +12,12 @@ #ifndef ROOT_TGLParametric #define ROOT_TGLParametric -#include <memory> - -#ifndef ROOT_TGLHistPainter #include "TGLHistPainter.h" -#endif -#ifndef ROOT_TGLUtil #include "TGLUtil.h" -#endif -#ifndef ROOT_TAxis #include "TAxis.h" -#endif -#ifndef ROOT_TF2 #include "TF2.h" -#endif + +#include <memory> class TString; @@ -42,7 +34,7 @@ typedef void (*ParametricEquation_t)(TGLVertex3 &, Double_t u, Double_t v); class TGLParametricEquation : public TNamed { private: - typedef std::auto_ptr<TF2> Ptr_t; + typedef std::unique_ptr<TF2> Ptr_t; Ptr_t fXEquation; Ptr_t fYEquation; @@ -56,7 +48,7 @@ private: Bool_t fConstrained; Bool_t fModified; - typedef std::auto_ptr<TGLHistPainter> Painter_t; + typedef std::unique_ptr<TGLHistPainter> Painter_t; //C++ compiler do not need TGLhistPainter definition here, but I'm not sure about CINT, //so I've included TGLHistPainter definition. Painter_t fPainter; diff --git a/graf3d/gl/inc/TGLTH3Composition.h b/graf3d/gl/inc/TGLTH3Composition.h index 04fa296304f..fbd640677db 100644 --- a/graf3d/gl/inc/TGLTH3Composition.h +++ b/graf3d/gl/inc/TGLTH3Composition.h @@ -57,7 +57,7 @@ private: typedef std::pair<const TH3 *, ETH3BinShape> TH3Pair_t; std::vector<TH3Pair_t> fHists; - std::auto_ptr<TGLHistPainter> fPainter; + std::unique_ptr<TGLHistPainter> fPainter; TGLTH3Composition(const TGLTH3Composition &rhs); TGLTH3Composition &operator = (const TGLTH3Composition &); diff --git a/math/mathcore/inc/Math/GoFTest.h b/math/mathcore/inc/Math/GoFTest.h index ead760bdd99..8e169a526b1 100644 --- a/math/mathcore/inc/Math/GoFTest.h +++ b/math/mathcore/inc/Math/GoFTest.h @@ -11,14 +11,10 @@ #ifndef ROOT_Math_GoFTest #define ROOT_Math_GoFTest -#include <memory> - -#ifndef ROOT_Math_WrappedFunction #include "Math/WrappedFunction.h" -#endif -#ifndef ROOT_TMath #include "TMath.h" -#endif + +#include <memory> /* */ @@ -182,7 +178,7 @@ private: GoFTest(GoFTest& gof); // Disallowed copy constructor GoFTest operator=(GoFTest& gof); // Disallowed assign operator - std::auto_ptr<IGenFunction> fCDF; + std::unique_ptr<IGenFunction> fCDF; EDistribution fDist; diff --git a/math/mathcore/inc/Math/IntegratorMultiDim.h b/math/mathcore/inc/Math/IntegratorMultiDim.h index 695f4de7050..c27c4ba142e 100644 --- a/math/mathcore/inc/Math/IntegratorMultiDim.h +++ b/math/mathcore/inc/Math/IntegratorMultiDim.h @@ -75,7 +75,7 @@ public: */ explicit IntegratorMultiDim(IntegrationMultiDim::Type type = IntegrationMultiDim::kDEFAULT, double absTol = -1, double relTol = -1, unsigned int ncall = 0) : - fIntegrator(0), fFunc(0) + fIntegrator(0) { fIntegrator = CreateIntegrator(type, absTol, relTol, ncall); } @@ -90,7 +90,7 @@ public: */ explicit IntegratorMultiDim(const IMultiGenFunction &f, IntegrationMultiDim::Type type = IntegrationMultiDim::kDEFAULT, double absTol = -1, double relTol = -1, unsigned int ncall = 0) : - fIntegrator(0), fFunc(0) + fIntegrator(0) { fIntegrator = CreateIntegrator(type, absTol, relTol, ncall); SetFunction(f); @@ -123,7 +123,7 @@ public: // disable copy constructur and assignment operator private: - IntegratorMultiDim(const IntegratorMultiDim &) : fIntegrator(0), fFunc(0) {} + IntegratorMultiDim(const IntegratorMultiDim &) : fIntegrator(0), fFunc(nullptr) {} IntegratorMultiDim & operator=(const IntegratorMultiDim &) { return *this; } public: @@ -156,7 +156,7 @@ public: */ template <class Function> void SetFunction(Function & f, unsigned int dim) { - fFunc = std::auto_ptr<IMultiGenFunction>(new WrappedMultiFunction<Function &> (f, dim) ); + fFunc.reset(new WrappedMultiFunction<Function &> (f, dim) ); fIntegrator->SetFunction(*fFunc); } @@ -208,7 +208,7 @@ protected: private: VirtualIntegratorMultiDim * fIntegrator; // pointer to multi-dimensional integrator base class - std::auto_ptr<IMultiGenFunction> fFunc; // pointer to owned function + std::unique_ptr<IMultiGenFunction> fFunc; // pointer to owned function }; diff --git a/math/mathcore/inc/Math/MinimTransformVariable.h b/math/mathcore/inc/Math/MinimTransformVariable.h index 78a24dc7bac..715c2a2a992 100644 --- a/math/mathcore/inc/Math/MinimTransformVariable.h +++ b/math/mathcore/inc/Math/MinimTransformVariable.h @@ -56,13 +56,13 @@ public: */ MinimTransformVariable () : fFix(false), fLowBound(false), fUpBound(false), fBounds(false), - fTransform(0), fLower(1), fUpper(0) + fLower(1), fUpper(0) {} // constructor for fixed variable MinimTransformVariable (double value) : fFix(true), fLowBound(false), fUpBound(false), fBounds(false), - fTransform(0), fLower(value), fUpper(value) + fLower(value), fUpper(value) {} // constructor for double bound variable @@ -90,7 +90,7 @@ public: fLower(rhs.fLower), fUpper(rhs.fUpper) { // swap auto_ptr - fTransform.reset( const_cast<MinimTransformVariable &>( rhs).fTransform.release() ) ; + fTransform.swap( const_cast<MinimTransformVariable &>( rhs).fTransform) ; } // assignment @@ -103,7 +103,7 @@ public: fLower = rhs.fLower; fUpper = rhs.fUpper; // swap auto_ptr - fTransform.reset( const_cast<MinimTransformVariable &>( rhs).fTransform.release() ) ; + fTransform.swap( const_cast<MinimTransformVariable &>( rhs).fTransform) ; return *this; } @@ -143,7 +143,7 @@ private: bool fLowBound; // has lower bound bool fUpBound; // has uppper bound param bool fBounds; // has double bound - std::auto_ptr< MinimizerVariableTransformation> fTransform; // pointer to the minimizer transformation + std::unique_ptr< MinimizerVariableTransformation> fTransform; // pointer to the minimizer transformation double fLower; // lower parameter limit double fUpper; // upper parameter limit diff --git a/math/mathcore/src/GoFTest.cxx b/math/mathcore/src/GoFTest.cxx index b09716a28fd..bece6b2dea9 100644 --- a/math/mathcore/src/GoFTest.cxx +++ b/math/mathcore/src/GoFTest.cxx @@ -130,8 +130,7 @@ namespace Math { } GoFTest::GoFTest( UInt_t sample1Size, const Double_t* sample1, UInt_t sample2Size, const Double_t* sample2 ) - : fCDF(std::auto_ptr<IGenFunction>((IGenFunction*)0)), - fDist(kUndefined), + : fDist(kUndefined), fSamples(std::vector<std::vector<Double_t> >(2)), fTestSampleFromH0(kFALSE) { Bool_t badSampleArg = sample1 == 0 || sample1Size == 0; @@ -159,8 +158,7 @@ namespace Math { } GoFTest::GoFTest(UInt_t sampleSize, const Double_t* sample, EDistribution dist) - : fCDF(std::auto_ptr<IGenFunction>((IGenFunction*)0)), - fDist(dist), + : fDist(dist), fSamples(std::vector<std::vector<Double_t> >(1)), fTestSampleFromH0(kTRUE) { Bool_t badSampleArg = sample == 0 || sampleSize == 0; @@ -259,7 +257,7 @@ namespace Math { default: break; } - fCDF = std::auto_ptr<IGenFunction>(cdf); + fCDF.reset(cdf); } void GoFTest::SetDistributionFunction(const IGenFunction& f, Bool_t isPDF, Double_t xmin, Double_t xmax) { @@ -269,9 +267,9 @@ namespace Math { fDist = kUserDefined; // function will be cloned inside the wrapper PDFIntegral of CDFWrapper classes if (isPDF) - fCDF = std::auto_ptr<IGenFunction>(new PDFIntegral(f, xmin, xmax) ); + fCDF.reset(new PDFIntegral(f, xmin, xmax) ); else - fCDF = std::auto_ptr<IGenFunction>(new CDFWrapper(f, xmin, xmax) ); + fCDF.reset(new CDFWrapper(f, xmin, xmax) ); } void GoFTest::Instantiate(const Double_t* sample, UInt_t sampleSize) { @@ -283,7 +281,7 @@ namespace Math { MATH_ERROR_MSG("GoFTest", msg.c_str()); assert(!badSampleArg); } - fCDF = std::auto_ptr<IGenFunction>((IGenFunction*)0); + fCDF.reset((IGenFunction*)0); fDist = kUserDefined; fMean = 0; fSigma = 0; diff --git a/math/unuran/inc/TUnuran.h b/math/unuran/inc/TUnuran.h index 05ab3bb2c2b..59abfffaaee 100644 --- a/math/unuran/inc/TUnuran.h +++ b/math/unuran/inc/TUnuran.h @@ -263,7 +263,7 @@ protected: UNUR_GEN * fGen; //pointer to the UnuRan C generator struct UNUR_DISTR * fUdistr; //pointer to the UnuRan C distribution struct UNUR_URNG * fUrng; // pointer to Unuran C random generator struct - std::auto_ptr<TUnuranBaseDist> fDist; // pointer for distribution wrapper + std::unique_ptr<TUnuranBaseDist> fDist; // pointer for distribution wrapper TRandom * fRng; //pointer to ROOT random number generator std::string fMethod; //string representing the method diff --git a/math/unuran/src/TUnuran.cxx b/math/unuran/src/TUnuran.cxx index c449f0c844d..1e9f8b81b0c 100644 --- a/math/unuran/src/TUnuran.cxx +++ b/math/unuran/src/TUnuran.cxx @@ -96,7 +96,7 @@ bool TUnuran::Init(const TUnuranContDist & distr, const std::string & method) // the distribution object is copied in and managed by this class // use auto_ptr to manage previously existing distribution objects TUnuranContDist * distNew = distr.Clone(); - fDist = std::auto_ptr< TUnuranBaseDist>(distNew); + fDist.reset(distNew); fMethod = method; if (! SetContDistribution(*distNew) ) return false; @@ -112,7 +112,7 @@ bool TUnuran::Init(const TUnuranMultiContDist & distr, const std::string & meth // the distribution object is copied in and managed by this class // use auto_ptr to manage previously existing distribution objects TUnuranMultiContDist * distNew = distr.Clone(); - fDist = std::auto_ptr< TUnuranBaseDist>(distNew); + fDist.reset(distNew); fMethod = method; if (! SetMultiDistribution(*distNew) ) return false; @@ -127,7 +127,7 @@ bool TUnuran::Init(const TUnuranDiscrDist & distr, const std::string & method ) // the distribution object is copied in and managed by this class // use auto_ptr to manage previously existing distribution objects TUnuranDiscrDist * distNew = distr.Clone(); - fDist = std::auto_ptr< TUnuranBaseDist>(distNew); + fDist.reset(distNew); fMethod = method; if (! SetDiscreteDistribution(*distNew) ) return false; @@ -141,7 +141,7 @@ bool TUnuran::Init(const TUnuranEmpDist & distr, const std::string & method ) { // the distribution object is copied in and managed by this class // use auto_ptr to manage previously existing distribution objects TUnuranEmpDist * distNew = distr.Clone(); - fDist = std::auto_ptr< TUnuranBaseDist>(distNew); + fDist.reset(distNew); fMethod = method; if (distr.IsBinned()) fMethod = "hist"; -- GitLab