Added default c-tor to ParseTree + improved createInstance.

createInstance now use move semantics for its parameters.
This commit is contained in:
Mike Lischke 2016-10-14 17:05:00 +02:00
parent 014070de66
commit aabf4baf60
2 changed files with 5 additions and 1 deletions

View File

@ -33,6 +33,9 @@
using namespace antlr4::tree;
ParseTree::ParseTree() : parent(nullptr) {
}
bool ParseTree::operator == (const ParseTree &other) const {
return &other == this;
}

View File

@ -45,6 +45,7 @@ namespace tree {
// ml: This class unites 4 Java classes: RuleNode, ParseTree, SyntaxTree and Tree.
class ANTLR4CPP_PUBLIC ParseTree {
public:
ParseTree();
virtual ~ParseTree() {}
/// The parent of this node. If the return value is null, then this
@ -102,7 +103,7 @@ namespace tree {
class ANTLR4CPP_PUBLIC ParseTreeTracker {
public:
template<typename T, typename ... Args>
T* createInstance(Args ... args) {
T* createInstance(Args&& ... args) {
static_assert(std::is_base_of<ParseTree, T>::value, "Argument must be a parse tree type");
T* result = new T(args...);
_allocated.push_back(result);