import mem import vector obj tree (Object) { var data: T var children: vector::vector<*tree> fun construct(dataIn: T): *tree { mem::maybe_copy_construct(&data, &dataIn) children.construct() return this } // Some of these don't really make much sense considering this tree is all about // heap allocated pointers. Best to have it for saftey, though fun copy_construct(old: *tree) { mem::maybe_copy_construct(&data, &old->data) children.copy_construct(&old->children) } // ditto fun operator=(other: tree):void { destruct() copy_construct(&other) } fun operator==(other: ref tree):bool { return data == other.data } fun destruct() { mem::maybe_destruct(&data) children.destruct() } }