Add a new constructor to ParseTree, and make the compCount variable mutable.
This commit is contained in:
parent
259398f2a3
commit
28175f2d96
@ -11,7 +11,7 @@ class ParseComponent {};
|
||||
|
||||
struct ParseTree: public ParseComponent {
|
||||
private:
|
||||
unsigned int compCount = 0;
|
||||
mutable unsigned int compCount = 0;
|
||||
protected:
|
||||
vector<ParseComponent> subComponents;
|
||||
public:
|
||||
@ -20,6 +20,8 @@ public:
|
||||
void add(const ParseComponent& component) { subComponents.push_back(component); ++compCount; };
|
||||
void addAll(const vector<ParseComponent>& components) { for (const auto& comp: components) add(comp); }
|
||||
void operator<<(const ParseComponent& component) { this->add(component); }
|
||||
explicit ParseTree(const ParseComponent& element): subComponents() { *this << element; }
|
||||
ParseTree(const initializer_list<ParseComponent>& elements): subComponents() { addAll(elements); }
|
||||
ParseTree(): subComponents() {};
|
||||
~ParseTree() = default;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user