|
@@ -63,8 +63,10 @@ struct {obj_name} {{
|
|
|
for field in obj_attrs['fields']:
|
|
|
name = field['name']
|
|
|
type_ = field['type']
|
|
|
+ # Because vector<bool> is packed, a temporary object is created so we can't return a reference.
|
|
|
+ ret_type = f'{type_}&' if type_ != 'bool' else type_
|
|
|
src.append(f'''\
|
|
|
- const {type_}& {name}() const {{
|
|
|
+ const {ret_type} {name}() const {{
|
|
|
if (!collection->{name}_loaded) {{
|
|
|
collection->val_{name} = collection->tds->track_branch_obj<vector<{type_}>>("{prefix}_{name}");
|
|
|
collection->{name}_loaded = true;
|
|
@@ -75,6 +77,10 @@ struct {obj_name} {{
|
|
|
src.append('};')
|
|
|
|
|
|
src.append(f'''
|
|
|
+bool operator==(const {obj_name}& obj1, const {obj_name}& obj2) {{
|
|
|
+ return obj1.idx == obj2.idx;
|
|
|
+}}
|
|
|
+
|
|
|
{obj_name} {obj_name}Collection::iter::operator*() {{
|
|
|
return {{collection, idx}};
|
|
|
}}
|