diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2024-09-25 13:40:11 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2024-09-25 13:40:11 +0200 |
commit | abcd9e4dcd17fe4bd50bc1d48ceccf6a3894986d (patch) | |
tree | 38d24b2580b864af04a3b123b3d1448370cd563a /libbuild2/parser.cxx | |
parent | 21bd200819d14f5bba18c2a87cccc18743cd7fde (diff) |
Use type-aware iteration in script for-loop (GH issue #436)
Diffstat (limited to 'libbuild2/parser.cxx')
-rw-r--r-- | libbuild2/parser.cxx | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/libbuild2/parser.cxx b/libbuild2/parser.cxx index e417d39..53f808c 100644 --- a/libbuild2/parser.cxx +++ b/libbuild2/parser.cxx @@ -5607,7 +5607,7 @@ namespace build2 } d {var, val_attrs, line, block, lhs, is}; - function<void (value&&, bool first)> iteration = + function<bool (value&&, bool first)> iteration = [this, &d] (value&& v, bool first) { // Rewind the stream. @@ -5645,12 +5645,15 @@ namespace build2 << "instead of " << t; lexer_ = ol; + return true; }; if (!iterate) { for (auto b (ns->begin ()), i (b), e (ns->end ()); i != e; ++i) { + bool first (i == b); + // Set the variable value. // bool pair (i->pair); @@ -5662,7 +5665,7 @@ namespace build2 if (etype != nullptr) typify (v, *etype, &var); - iteration (move (v), i == b); + iteration (move (v), first); } } else |