summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/netlist/prg/nltool.cpp
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2017-03-30 15:23:23 +1100
committer Vas Crabb <vas@vastheman.com>2017-03-30 15:51:14 +1100
commit5e8fefbb1214e9936253a81da4946cc42cc20b9d (patch)
tree30d297c7eb05c68326488bf1618505a8d00bd135 /src/lib/netlist/prg/nltool.cpp
parent35b673ea45da6b4759f170813f99c124c7db9d70 (diff)
Turn psring iterator into a real forward iterator that works with standard algorithms.
There are a few changes to achieve this: * Rename to const_iterator since it's immutable * Typedef iterator to const_iterator for now as there's no mutable iterator * Add default constrcutor and operator-> required by concept, const-qualify operators * Remove operator+ and operator+= since it's not a random-access iterator (use std::next and std::advance instead) * Return reference/pointer to a proxy rather than a code_t value from opertator*/operator-> The final change is required to meet the requirement that operator* for two equivalent forward iterators return an equivalent reference. The pstring doesn't actually contain a sequence of code_t, so there's no way to return a reference to code_t directly. Instead, a reference to a proxy object aliased on the string storage is returned. The proxy is implicitly convertible to code_t. The most noticeable side effect is that auto c = *s.begin() or for (auto c : s) won't work. You need to do for (auto &c : s) or for (code_t c : s) instead.
Diffstat (limited to 'src/lib/netlist/prg/nltool.cpp')
-rw-r--r--src/lib/netlist/prg/nltool.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/lib/netlist/prg/nltool.cpp b/src/lib/netlist/prg/nltool.cpp
index e797399b9a1..ba0526b5408 100644
--- a/src/lib/netlist/prg/nltool.cpp
+++ b/src/lib/netlist/prg/nltool.cpp
@@ -421,7 +421,7 @@ void tool_app_t::mac_out(const pstring &s, const bool cont)
if (cont)
{
unsigned adj = 0;
- for (auto x : s)
+ for (auto &x : s)
adj += (x == '\t' ? 3 : 0);
pout("{1}\\\n", s.rpad(" ", RIGHT-1-adj));
}