Skip to content
This repository was archived by the owner on Mar 25, 2025. It is now read-only.

Commit 25e654c

Browse files
authored
Remove virtual from set_parent_for_children (#296)
* Remove virtual from set_parent_for_children (issue #296) - set_parent_for_children is called only in the constructors. The virtual keyword unnecessary and generates only confusion. - Remove virtual from set_parent_for_children (issue #295) - set_parent_in_children() visibility is now private Co-authored-by: Tristan Carel <tristan.carel@epfl.ch> fixes #295
1 parent 54e41a8 commit 25e654c

2 files changed

Lines changed: 6 additions & 15 deletions

File tree

src/language/templates/ast/ast.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,6 @@ void Ast::set_parent(Ast* p) {
7373
parent = p;
7474
}
7575

76-
void Ast::set_parent_in_children() {
77-
throw std::runtime_error("set_parent_in_children not implemented");
78-
}
79-
8076

8177
{% for node in nodes %}
8278

src/language/templates/ast/ast.hpp

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -348,14 +348,6 @@ struct Ast: public std::enable_shared_from_this<Ast> {
348348
* \ref Check Ast::parent for more information
349349
*/
350350
virtual void set_parent(Ast* p);
351-
352-
/**
353-
*\brief Set this object as parent for all the children
354-
*
355-
* This should be called in every object (with children) constructor
356-
* to set the parents.
357-
*/
358-
virtual void set_parent_in_children();
359351
};
360352

361353
/** @} */ // end of ast_class
@@ -714,12 +706,15 @@ struct Ast: public std::enable_shared_from_this<Ast> {
714706
{% endif %}
715707

716708
{% if node.children %}
709+
private:
717710
/**
718-
* \brief Set parents in children
711+
*\brief Set this object as parent for all the children
719712
*
720-
* Usually called in constructors
713+
* This should be called in every object (with children) constructor
714+
* to set parents. Since it is called only in the constructors it
715+
* should not be virtual to avoid ambiguities (issue #295).
721716
*/
722-
virtual void set_parent_in_children() override;
717+
void set_parent_in_children();
723718
{% endif %}
724719
};
725720

0 commit comments

Comments
 (0)