From 5e8fefbb1214e9936253a81da4946cc42cc20b9d Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Thu, 30 Mar 2017 15:23:23 +1100 Subject: 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. --- src/lib/netlist/plib/pfunction.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/lib/netlist/plib/pfunction.cpp') diff --git a/src/lib/netlist/plib/pfunction.cpp b/src/lib/netlist/plib/pfunction.cpp index 0f48860d15b..7113a6e07fb 100644 --- a/src/lib/netlist/plib/pfunction.cpp +++ b/src/lib/netlist/plib/pfunction.cpp @@ -86,7 +86,7 @@ static int get_prio(pstring v) { if (v == "(" || v == ")") return 1; - else if (v.left(v.begin()+1) >= "a" && v.left(v.begin()+1) <= "z") + else if (v.left(std::next(v.begin(),1)) >= "a" && v.left(std::next(v.begin(),1)) <= "z") return 0; else if (v == "*" || v == "/") return 20; -- cgit v1.2.3-70-g09d2