table: make NameTree enumeration usable with range-based for
NameTree::fullEnumerate and NameTree::partialEnumerate are changed
to return a type usable with range-based for.
NameTree enumeration test cases are also simplified.
refs #2155
Change-Id: I315d9502d2194670aa7054ab956ededefb0c7ca0
diff --git a/daemon/table/strategy-choice.cpp b/daemon/table/strategy-choice.cpp
index f39df1c..85aade6 100644
--- a/daemon/table/strategy-choice.cpp
+++ b/daemon/table/strategy-choice.cpp
@@ -259,26 +259,29 @@
// reset StrategyInfo on a portion of NameTree,
// where entry's effective strategy is covered by the changing StrategyChoice entry
const name_tree::Entry* rootNte = m_nameTree.get(entry).get();
- auto ntChanged = m_nameTree.partialEnumerate(entry.getPrefix(),
+ auto&& ntChanged = m_nameTree.partialEnumerate(entry.getPrefix(),
[&rootNte] (const name_tree::Entry& nte) -> std::pair<bool, bool> {
if (&nte == rootNte) {
- return { true, true };
+ return {true, true};
}
if (static_cast<bool>(nte.getStrategyChoiceEntry())) {
- return { false, false };
+ return {false, false};
}
- return { true, true };
+ return {true, true};
});
- std::for_each(ntChanged, m_nameTree.end(), &clearStrategyInfo);
+ for (const name_tree::Entry& nte : ntChanged) {
+ clearStrategyInfo(nte);
+ }
}
StrategyChoice::const_iterator
StrategyChoice::begin() const
{
- return const_iterator(m_nameTree.fullEnumerate(
+ auto&& enumerable = m_nameTree.fullEnumerate(
[] (const name_tree::Entry& entry) {
return static_cast<bool>(entry.getStrategyChoiceEntry());
- }));
+ });
+ return const_iterator(enumerable.begin());
}
} // namespace nfd