From aabf4baf607f5f48e26b84cbd88b2ee67726ac41 Mon Sep 17 00:00:00 2001 From: Mike Lischke Date: Fri, 14 Oct 2016 17:05:00 +0200 Subject: [PATCH] Added default c-tor to ParseTree + improved createInstance. createInstance now use move semantics for its parameters. --- runtime/Cpp/runtime/src/tree/ParseTree.cpp | 3 +++ runtime/Cpp/runtime/src/tree/ParseTree.h | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/runtime/Cpp/runtime/src/tree/ParseTree.cpp b/runtime/Cpp/runtime/src/tree/ParseTree.cpp index 927e60979..4cec69d4d 100755 --- a/runtime/Cpp/runtime/src/tree/ParseTree.cpp +++ b/runtime/Cpp/runtime/src/tree/ParseTree.cpp @@ -33,6 +33,9 @@ using namespace antlr4::tree; +ParseTree::ParseTree() : parent(nullptr) { +} + bool ParseTree::operator == (const ParseTree &other) const { return &other == this; } diff --git a/runtime/Cpp/runtime/src/tree/ParseTree.h b/runtime/Cpp/runtime/src/tree/ParseTree.h index 8b772a9e3..b348ffa8f 100755 --- a/runtime/Cpp/runtime/src/tree/ParseTree.h +++ b/runtime/Cpp/runtime/src/tree/ParseTree.h @@ -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 - T* createInstance(Args ... args) { + T* createInstance(Args&& ... args) { static_assert(std::is_base_of::value, "Argument must be a parse tree type"); T* result = new T(args...); _allocated.push_back(result);