You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 28, 2023. It is now read-only.
The original implementation of schedule trees with "element" classes was
relying on a manual macro-based dynamic dispatch to copy schedule tree
nodes. Arguably, this is not desirable in the C++ code where the same
behavior can be achieved through language mechanisms (virtual functions
or CRTP). Since copy constructors cannot be overloaded, introduce an
abstract "clone" method to ScheduleTree and override it in all
subclasses to produce copies of the given node wrapped in a unique
pointer to the base class. Note that children of the given node are not
copied to remain consistent with the existing uses. Replace macro-based
dispatch with a call to the virtual function.
Using language featuers for dispatch is less error-prone and converts
run-time errors (e.g., unhandled type in macro-based if/else sequence)
into compile-time errors (e.g., attempting to instantiate an abstract
class because the abstract function was not implemented). It also
localizes the changes to be made to the ScheduleTree API when
introducing or removing a new node type.
0 commit comments