diff -r 635d7dfdb8a3 -r a7be43584cdd src/base/statistics.hh --- a/src/base/statistics.hh Mon Sep 29 11:41:27 2014 +0100 +++ b/src/base/statistics.hh Mon Sep 29 11:41:45 2014 +0100 @@ -57,6 +57,7 @@ #include #include #include +#include #include #include @@ -66,7 +67,6 @@ #include "base/cast.hh" #include "base/cprintf.hh" #include "base/intmath.hh" -#include "base/refcnt.hh" #include "base/str.hh" #include "base/types.hh" @@ -2049,7 +2049,7 @@ * Base class for formula statistic node. These nodes are used to build a tree * that represents the formula. */ -class Node : public RefCounted +class Node { public: /** @@ -2074,8 +2074,8 @@ virtual std::string str() const = 0; }; -/** Reference counting pointer to a function Node. */ -typedef RefCountingPtr NodePtr; +/** Shared pointer to a function Node. */ +typedef std::shared_ptr NodePtr; class ScalarStatNode : public Node { @@ -2988,7 +2988,9 @@ * Copy the given pointer to this class. * @param n A pointer to a Node object to copy. */ - Temp(NodePtr n) : node(n) { } + Temp(const NodePtr &n) : node(n) { } + + Temp(NodePtr &&n) : node(std::move(n)) { } /** * Return the node pointer. @@ -3154,51 +3156,51 @@ inline Temp operator+(Temp l, Temp r) { - return NodePtr(new BinaryNode >(l, r)); + return Temp(std::make_shared > >(l, r)); } inline Temp operator-(Temp l, Temp r) { - return NodePtr(new BinaryNode >(l, r)); + return Temp(std::make_shared > >(l, r)); } inline Temp operator*(Temp l, Temp r) { - return NodePtr(new BinaryNode >(l, r)); + return Temp(std::make_shared > >(l, r)); } inline Temp operator/(Temp l, Temp r) { - return NodePtr(new BinaryNode >(l, r)); + return Temp(std::make_shared > >(l, r)); } inline Temp operator-(Temp l) { - return NodePtr(new UnaryNode >(l)); + return Temp(std::make_shared > >(l)); } template inline Temp constant(T val) { - return NodePtr(new ConstNode(val)); + return Temp(std::make_shared >(val)); } template inline Temp constantVector(T val) { - return NodePtr(new ConstVectorNode(val)); + return Temp(std::make_shared >(val)); } inline Temp sum(Temp val) { - return NodePtr(new SumNode >(val)); + return Temp(std::make_shared > >(val)); } /** Dump all statistics data to the registered outputs */