Skip to content

Instantly share code, notes, and snippets.

@Siapran
Created February 6, 2020 20:07
Show Gist options
  • Save Siapran/560353c69f788c29880dd5709e74bd8d to your computer and use it in GitHub Desktop.
Save Siapran/560353c69f788c29880dd5709e74bd8d to your computer and use it in GitHub Desktop.
std::optional<lager::cursor<Volume>> volumeCursorAt(
lager::cursor<VolumeTree> treeCursor, VolumeTree const &tree, int &index)
{
if (index == 0) {
return {treeCursor[&VolumeTree::volume]};
} else {
size_t i = 0;
for (auto const &child : tree.children) {
--index;
std::optional<lager::cursor<Volume>> res =
volumeCursorAt(
treeCursor[&VolumeTree::children][i][&VolumeVolumeRegistration::tree],
child.tree,
index);
if (res.has_value()) {
return res;
}
++i;
}
return std::nullopt;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment