Skip to content

Commit

Permalink
Make older compilers happy with in place construction
Browse files Browse the repository at this point in the history
  • Loading branch information
tmadlener committed Jun 11, 2024
1 parent 5302d39 commit 40b7634
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
10 changes: 10 additions & 0 deletions include/podio/utilities/RootHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ namespace root_utils {
/// write a collection. Needed to cache the branch pointers and avoid having to
/// get them from a TTree/TChain for every event.
struct CollectionBranches {
CollectionBranches() = default;
~CollectionBranches() = default;
CollectionBranches(const CollectionBranches&) = delete;
CollectionBranches& operator=(const CollectionBranches&) = delete;
CollectionBranches(CollectionBranches&&) = default;
CollectionBranches& operator=(CollectionBranches&&) = default;

CollectionBranches(TBranch* dataBranch) : data(dataBranch) {
}

TBranch* data{nullptr};
std::vector<TBranch*> refs{};
std::vector<TBranch*> vecs{};
Expand Down
2 changes: 1 addition & 1 deletion src/ROOTLegacyReader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ void ROOTLegacyReader::createCollectionBranches(const std::vector<root_utils::Co

m_storedClasses.emplace_back(name, std::make_tuple(collType, isSubsetColl, collSchemaVersion, collectionIndex++));

m_collectionBranches.push_back(branches);
m_collectionBranches.emplace_back(std::move(branches));
}
}

Expand Down
7 changes: 3 additions & 4 deletions src/ROOTReader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,7 @@ void ROOTReader::initCategory(CategoryInfo& catInfo, const std::string& category
// Finally set up the branches for the parameters
if (m_fileVersion < podio::version::Version{0, 99, 99}) {
root_utils::CollectionBranches paramBranches{};
paramBranches.data = root_utils::getBranch(catInfo.chain.get(), root_utils::paramBranchName);
catInfo.branches.push_back(paramBranches);
catInfo.branches.emplace_back(root_utils::getBranch(catInfo.chain.get(), root_utils::paramBranchName));
} else {
catInfo.branches.emplace_back(root_utils::getBranch(catInfo.chain.get(), root_utils::intKeyName));
catInfo.branches.emplace_back(root_utils::getBranch(catInfo.chain.get(), root_utils::intValueName));
Expand Down Expand Up @@ -373,7 +372,7 @@ createCollectionBranchesIndexBased(TChain* chain, const podio::CollectionIDTable
collBranches.emplace_back(std::move(branches));
}

return {collBranches, storedClasses};
return {std::move(collBranches), storedClasses};
}

std::tuple<std::vector<root_utils::CollectionBranches>, std::vector<std::pair<std::string, detail::CollectionInfo>>>
Expand Down Expand Up @@ -419,7 +418,7 @@ createCollectionBranches(TChain* chain, const podio::CollectionIDTable& idTable,
collBranches.emplace_back(std::move(branches));
}

return {collBranches, storedClasses};
return {std::move(collBranches), storedClasses};
}

} // namespace podio
2 changes: 1 addition & 1 deletion src/ROOTWriter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ void ROOTWriter::initBranches(CategoryInfo& catInfo, const std::vector<root_util
}
}

catInfo.branches.push_back(branches);
catInfo.branches.emplace_back(std::move(branches));
catInfo.collInfo.emplace_back(catInfo.idTable.collectionID(name).value(), std::string(coll->getTypeName()),
coll->isSubsetCollection(), coll->getSchemaVersion());
}
Expand Down

0 comments on commit 40b7634

Please sign in to comment.