From 61a2019ee0aa9a93646bd43c47ff9b11156d37a3 Mon Sep 17 00:00:00 2001 From: Axel Naumann 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 d0f81577cafbc..5bc1e4858cf83 100644 --- a/core/macosx/inc/TMacOSXSystem.h +++ b/core/macosx/inc/TMacOSXSystem.h @@ -13,11 +13,9 @@ #ifndef ROOT_TMacOSXSystem #define ROOT_TMacOSXSystem -#include - -#ifndef ROOT_TUnixSystem #include "TUnixSystem.h" -#endif + +#include //////////////////////////////////////////////////////////////////// // // @@ -58,7 +56,7 @@ class TMacOSXSystem : public TUnixSystem { void ProcessApplicationDefinedEvent(void *event); - std::auto_ptr fPimpl; //! + std::unique_ptr fPimpl; //! bool fCocoaInitialized; //! bool fFirstDispatch; //! diff --git a/graf2d/cocoa/inc/TGCocoa.h b/graf2d/cocoa/inc/TGCocoa.h index 4f17034cc0669..0959c3af8bc9d 100644 --- a/graf2d/cocoa/inc/TGCocoa.h +++ b/graf2d/cocoa/inc/TGCocoa.h @@ -13,21 +13,15 @@ #ifndef ROOT_TGCocoa #define ROOT_TGCocoa -#include -#include -#include -#include -#include - -#ifndef ROOT_CocoaGuiTypes #include "CocoaGuiTypes.h" -#endif -#ifndef ROOT_TVirtualX #include "TVirtualX.h" -#endif -#ifndef ROOT_X11Atoms #include "X11Atoms.h" -#endif + +#include +#include +#include +#include +#include /// \defgroup cocoa Cocoa backend /// \brief Interface to MacOS native graphics system. @@ -447,7 +441,7 @@ class TGCocoa : public TVirtualX { Drawable_t fSelectedDrawable; - std::auto_ptr fPimpl; //! + std::unique_ptr fPimpl; //! Int_t fCocoaDraw; EDrawMode fDrawMode; diff --git a/graf3d/gl/inc/TGL5D.h b/graf3d/gl/inc/TGL5D.h index b07e73a72d784..4a820fc4fc82f 100644 --- a/graf3d/gl/inc/TGL5D.h +++ b/graf3d/gl/inc/TGL5D.h @@ -11,21 +11,13 @@ #ifndef ROOT_TGL5D #define ROOT_TGL5D -#include -#include - -#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 +#include class TGL5DPainter; class TTree; @@ -106,7 +98,7 @@ class TGL5DDataSet : public TNamed { //V4 can have a string type. Bool_t fV4IsString; //Painter to visualize dataset. - std::auto_ptr fPainter; + std::unique_ptr fPainter; //Indices of points, selected for some iso-level. std::vector fIndices; diff --git a/graf3d/gl/inc/TGLHistPainter.h b/graf3d/gl/inc/TGLHistPainter.h index d4c7a6b12ee67..9e53ece29f602 100644 --- a/graf3d/gl/inc/TGLHistPainter.h +++ b/graf3d/gl/inc/TGLHistPainter.h @@ -12,17 +12,11 @@ #ifndef ROOT_TGLHistPainter #define ROOT_TGLHistPainter -#include - -#ifndef ROOT_TVirtualHistPainter #include "TVirtualHistPainter.h" -#endif -#ifndef ROOT_TGLPlotPainter #include "TGLPlotPainter.h" -#endif -#ifndef ROOT_TGLPlotCamera #include "TGLPlotCamera.h" -#endif + +#include /* 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 fDefaultPainter; + std::unique_ptr fDefaultPainter; //This member can have different dynamic types: TGLLegoPainter, etc. - std::auto_ptr fGLPainter; + std::unique_ptr fGLPainter; TGLParametricEquation *fEq; TH1 *fHist; diff --git a/graf3d/gl/inc/TGLParametric.h b/graf3d/gl/inc/TGLParametric.h index 45291a29b84d9..ce96ea1afc823 100644 --- a/graf3d/gl/inc/TGLParametric.h +++ b/graf3d/gl/inc/TGLParametric.h @@ -12,20 +12,12 @@ #ifndef ROOT_TGLParametric #define ROOT_TGLParametric -#include - -#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 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 Ptr_t; + typedef std::unique_ptr Ptr_t; Ptr_t fXEquation; Ptr_t fYEquation; @@ -56,7 +48,7 @@ class TGLParametricEquation : public TNamed { Bool_t fConstrained; Bool_t fModified; - typedef std::auto_ptr Painter_t; + typedef std::unique_ptr 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 04fa296304fdb..fbd640677db98 100644 --- a/graf3d/gl/inc/TGLTH3Composition.h +++ b/graf3d/gl/inc/TGLTH3Composition.h @@ -57,7 +57,7 @@ class TGLTH3Composition : public TH3C { typedef std::pair TH3Pair_t; std::vector fHists; - std::auto_ptr fPainter; + std::unique_ptr 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 ead760bdd9963..8e169a526b1f9 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 - -#ifndef ROOT_Math_WrappedFunction #include "Math/WrappedFunction.h" -#endif -#ifndef ROOT_TMath #include "TMath.h" -#endif + +#include /* */ @@ -182,7 +178,7 @@ class GoFTest { GoFTest(GoFTest& gof); // Disallowed copy constructor GoFTest operator=(GoFTest& gof); // Disallowed assign operator - std::auto_ptr fCDF; + std::unique_ptr fCDF; EDistribution fDist; diff --git a/math/mathcore/inc/Math/IntegratorMultiDim.h b/math/mathcore/inc/Math/IntegratorMultiDim.h index 695f4de705006..c27c4ba142e0a 100644 --- a/math/mathcore/inc/Math/IntegratorMultiDim.h +++ b/math/mathcore/inc/Math/IntegratorMultiDim.h @@ -75,7 +75,7 @@ class IntegratorMultiDim { */ 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 @@ class IntegratorMultiDim { */ 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 @@ class IntegratorMultiDim { // 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 @@ class IntegratorMultiDim { */ template void SetFunction(Function & f, unsigned int dim) { - fFunc = std::auto_ptr(new WrappedMultiFunction (f, dim) ); + fFunc.reset(new WrappedMultiFunction (f, dim) ); fIntegrator->SetFunction(*fFunc); } @@ -208,7 +208,7 @@ class IntegratorMultiDim { private: VirtualIntegratorMultiDim * fIntegrator; // pointer to multi-dimensional integrator base class - std::auto_ptr fFunc; // pointer to owned function + std::unique_ptr fFunc; // pointer to owned function }; diff --git a/math/mathcore/inc/Math/MinimTransformVariable.h b/math/mathcore/inc/Math/MinimTransformVariable.h index 78a24dc7bac5e..715c2a2a9927e 100644 --- a/math/mathcore/inc/Math/MinimTransformVariable.h +++ b/math/mathcore/inc/Math/MinimTransformVariable.h @@ -56,13 +56,13 @@ class MinimTransformVariable { */ 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 @@ class MinimTransformVariable { fLower(rhs.fLower), fUpper(rhs.fUpper) { // swap auto_ptr - fTransform.reset( const_cast( rhs).fTransform.release() ) ; + fTransform.swap( const_cast( rhs).fTransform) ; } // assignment @@ -103,7 +103,7 @@ class MinimTransformVariable { fLower = rhs.fLower; fUpper = rhs.fUpper; // swap auto_ptr - fTransform.reset( const_cast( rhs).fTransform.release() ) ; + fTransform.swap( const_cast( rhs).fTransform) ; return *this; } @@ -143,7 +143,7 @@ class MinimTransformVariable { 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 b09716a28fd53..bece6b2dea9c1 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*)0)), - fDist(kUndefined), + : fDist(kUndefined), fSamples(std::vector >(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*)0)), - fDist(dist), + : fDist(dist), fSamples(std::vector >(1)), fTestSampleFromH0(kTRUE) { Bool_t badSampleArg = sample == 0 || sampleSize == 0; @@ -259,7 +257,7 @@ namespace Math { default: break; } - fCDF = std::auto_ptr(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(new PDFIntegral(f, xmin, xmax) ); + fCDF.reset(new PDFIntegral(f, xmin, xmax) ); else - fCDF = std::auto_ptr(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*)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 05ab3bb2c2b53..59abfffaaeedb 100644 --- a/math/unuran/inc/TUnuran.h +++ b/math/unuran/inc/TUnuran.h @@ -263,7 +263,7 @@ class TUnuran { 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 fDist; // pointer for distribution wrapper + std::unique_ptr 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 c449f0c844d8c..1e9f8b81b0c5c 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";