for (pugi::xml_node child: tool)
+for (pugi::xml_node child: tool) ...
+diff --git a/docs/manual.adoc b/docs/manual.adoc index 45b2f3c..70436e8 100644 --- a/docs/manual.adoc +++ b/docs/manual.adoc @@ -1039,7 +1039,19 @@ While using `children()` makes the intent of the code clear, note that each node [source] ---- -for (pugi::xml_node child: tool) +for (pugi::xml_node child: tool) ... +---- + +When using C{plus}{plus}20, you can also use nodes as well as objects returned by `children()` and `attributes()` functions as ranges: + +[source] +---- +auto tf = + tools.children("Tool") + | std::views::filter([](auto node) { return node.attribute("AllowRemote").as_bool(); }) + | std::views::reverse; + +for (pugi::xml_node tool: tf) ... ---- [[access.iterators]] diff --git a/docs/manual.html b/docs/manual.html index 0539967..04c56e8 100644 --- a/docs/manual.html +++ b/docs/manual.html @@ -448,6 +448,7 @@ pre.pygments .tok-c1 { color: #3D7B7B; font-style: italic } /* Comment.Single */ pre.pygments .tok-cs { color: #3D7B7B; font-style: italic } /* Comment.Special */ pre.pygments .tok-gd { color: #A00000 } /* Generic.Deleted */ pre.pygments .tok-ge { font-style: italic } /* Generic.Emph */ +pre.pygments .tok-ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */ pre.pygments .tok-gr { color: #E40000 } /* Generic.Error */ pre.pygments .tok-gh { color: #000080; font-weight: bold } /* Generic.Heading */ pre.pygments .tok-gi { color: #008400 } /* Generic.Inserted */ @@ -2300,7 +2301,20 @@ If your C++ compiler supports range-based for-loop (this is a C++
for (pugi::xml_node child: tool)
+for (pugi::xml_node child: tool) ...
+When using C++20, you can also use nodes as well as objects returned by children()
and attributes()
functions as ranges:
auto tf =
+ tools.children("Tool")
+ | std::views::filter([](auto node) { return node.attribute("AllowRemote").as_bool(); })
+ | std::views::reverse;
+
+for (pugi::xml_node tool: tf) ...