diff --git a/Environment/VolumeTreeNode.h b/Environment/VolumeTreeNode.h index 7a8b2e785f134ba59546e5622366a03c8f7554a4..d996758625969d82860ab8638c7e4e64328381a2 100644 --- a/Environment/VolumeTreeNode.h +++ b/Environment/VolumeTreeNode.h @@ -75,15 +75,12 @@ namespace corsika::environment { */ template <typename TCallable, bool preorder = true> void walk(TCallable func) { - if constexpr (preorder) { - func(*this); - std::for_each(fChildNodes.begin(), fChildNodes.end(), - [&](auto& v) { v->walk(func); }); - } else { - std::for_each(fChildNodes.begin(), fChildNodes.end(), - [&](auto& v) { v->walk(func); }); - func(*this); - } + if constexpr (preorder) { func(*this); } + + std::for_each(fChildNodes.begin(), fChildNodes.end(), + [&](auto& v) { v->walk(func); }); + + if constexpr (!preorder) { func(*this); }; } void AddChild(VTNUPtr pChild) {