Skip to content

Commit

Permalink
Replace uses of auto_ptr by unique_ptr in headers.
Browse files Browse the repository at this point in the history
This allows us to turn off -Wno-deprecated-declarations, to make R__DEPRECATED useful.
  • Loading branch information
Axel-Naumann committed Sep 29, 2016
1 parent 182ef02 commit 61a2019
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 83 deletions.
8 changes: 3 additions & 5 deletions core/macosx/inc/TMacOSXSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@
#ifndef ROOT_TMacOSXSystem
#define ROOT_TMacOSXSystem

#include <memory>

#ifndef ROOT_TUnixSystem
#include "TUnixSystem.h"
#endif

#include <memory>

////////////////////////////////////////////////////////////////////
// //
Expand Down Expand Up @@ -58,7 +56,7 @@ class TMacOSXSystem : public TUnixSystem {

void ProcessApplicationDefinedEvent(void *event);

std::auto_ptr<ROOT::MacOSX::Detail::MacOSXSystem> fPimpl; //!
std::unique_ptr<ROOT::MacOSX::Detail::MacOSXSystem> fPimpl; //!
bool fCocoaInitialized; //!
bool fFirstDispatch; //!

Expand Down
20 changes: 7 additions & 13 deletions graf2d/cocoa/inc/TGCocoa.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -447,7 +441,7 @@ class TGCocoa : public TVirtualX {

Drawable_t fSelectedDrawable;

std::auto_ptr<ROOT::MacOSX::Details::CocoaPrivate> fPimpl; //!
std::unique_ptr<ROOT::MacOSX::Details::CocoaPrivate> fPimpl; //!
Int_t fCocoaDraw;

EDrawMode fDrawMode;
Expand Down
16 changes: 4 additions & 12 deletions graf3d/gl/inc/TGL5D.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -106,7 +98,7 @@ class TGL5DDataSet : public TNamed {
//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;

Expand Down
14 changes: 4 additions & 10 deletions graf3d/gl/inc/TGLHistPainter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down
16 changes: 4 additions & 12 deletions graf3d/gl/inc/TGLParametric.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand All @@ -56,7 +48,7 @@ class TGLParametricEquation : public TNamed {
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;
Expand Down
2 changes: 1 addition & 1 deletion graf3d/gl/inc/TGLTH3Composition.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class TGLTH3Composition : public TH3C {
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 &);
Expand Down
10 changes: 3 additions & 7 deletions math/mathcore/inc/Math/GoFTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>

/*
*/
Expand Down Expand Up @@ -182,7 +178,7 @@ class GoFTest {
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;
Expand Down
10 changes: 5 additions & 5 deletions math/mathcore/inc/Math/IntegratorMultiDim.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -156,7 +156,7 @@ class IntegratorMultiDim {
*/
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);
}

Expand Down Expand Up @@ -208,7 +208,7 @@ class IntegratorMultiDim {
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


};
Expand Down
10 changes: 5 additions & 5 deletions math/mathcore/inc/Math/MinimTransformVariable.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -90,7 +90,7 @@ class MinimTransformVariable {
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
Expand All @@ -103,7 +103,7 @@ class MinimTransformVariable {
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;
}

Expand Down Expand Up @@ -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

Expand Down
14 changes: 6 additions & 8 deletions math/mathcore/src/GoFTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion math/unuran/inc/TUnuran.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<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

Expand Down
8 changes: 4 additions & 4 deletions math/unuran/src/TUnuran.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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";
Expand Down

0 comments on commit 61a2019

Please sign in to comment.