|
[Rivet-svn] rivet: pyext now understands unique_ptr. Completes ptr changes f...Rivet Mercurial rivet at projects.hepforge.orgSat Apr 9 17:45:01 BST 2016
details: https://rivet.hepforge.org/hg/rivet/rev/b7daedaa818a branches: changeset: 5116:b7daedaa818a user: David Grellscheid <david.grellscheid at durham.ac.uk> date: Sat Apr 09 17:38:24 2016 +0100 description: pyext now understands unique_ptr. Completes ptr changes for 2.5 diffs (truncated from 254 to 50 lines): --- a/include/Rivet/AnalysisBuilder.hh Sat Apr 09 12:03:00 2016 +0100 +++ b/include/Rivet/AnalysisBuilder.hh Sat Apr 09 17:38:24 2016 +0100 @@ -20,24 +20,22 @@ public: /// Default constructor - AnalysisBuilderBase() { } + AnalysisBuilderBase() = default; /// Constructor with alias name - AnalysisBuilderBase(const string& alias) { _alias = alias; } + AnalysisBuilderBase(const string& alias) : _alias(alias) {} /// Destructor - virtual ~AnalysisBuilderBase() { } + virtual ~AnalysisBuilderBase() = default; /// Factory method, to be implemented by the analysis-specific derived class - virtual Analysis* mkAnalysis() const = 0; + virtual unique_ptr<Analysis> mkAnalysis() const = 0; /// Get the analysis' name, by asking it directly /// @todo Could avoid this slow lookup by passing it via the constructor... at the cost of potential inconsistency string name() const { - Analysis* a = mkAnalysis(); - const string rtn = a->name(); - delete a; - return rtn; + auto a = mkAnalysis(); + return a->name(); } /// @brief Get any optional alias name attached to this builder @@ -77,8 +75,8 @@ _register(); } - Analysis* mkAnalysis() const { - return new T(); + unique_ptr<Analysis> mkAnalysis() const { + return unique_ptr<T>(new T); } }; --- a/include/Rivet/AnalysisLoader.hh Sat Apr 09 12:03:00 2016 +0100 +++ b/include/Rivet/AnalysisLoader.hh Sat Apr 09 17:38:24 2016 +0100 @@ -26,10 +26,10 @@ /// Get an analysis by name. /// Warning: a name arg which matches no known analysis will return a null /// pointer. Check your return values before using them!
More information about the Rivet-svn mailing list |