Skip to content

Commit 82f5f83

Browse files
committed
found
1 parent 3e07032 commit 82f5f83

File tree

1 file changed

+24
-16
lines changed

1 file changed

+24
-16
lines changed

lib/findtoken.h

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,12 @@ T* findToken(T* start, const Token* end, const std::function<bool(const Token*)>
7474
return result;
7575
}
7676

77-
template<class T,
78-
class Found,
79-
REQUIRES("T must be a Token class", std::is_convertible<T*, const Token*> )>
77+
template<class T, REQUIRES("T must be a Token class", std::is_convertible<T*, const Token*> )>
8078
bool findTokensSkipDeadCodeImpl(const Library& library,
8179
T* start,
8280
const Token* end,
8381
const std::function<bool(const Token*)>& pred,
84-
Found found,
82+
std::function<bool(T*)> found,
8583
const std::function<std::vector<MathLib::bigint>(const Token*)>& evaluate,
8684
bool skipUnevaluated)
8785
{
@@ -181,15 +179,18 @@ std::vector<T*> findTokensSkipDeadCode(const Library& library,
181179
const std::function<std::vector<MathLib::bigint>(const Token*)>& evaluate)
182180
{
183181
std::vector<T*> result;
182+
183+
std::function<bool(T*)> f = [&](T* tok) {
184+
result.push_back(tok);
185+
return false;
186+
};
187+
184188
(void)findTokensSkipDeadCodeImpl(
185189
library,
186190
start,
187191
end,
188192
pred,
189-
[&](T* tok) {
190-
result.push_back(tok);
191-
return false;
192-
},
193+
std::move(f),
193194
evaluate,
194195
false);
195196
return result;
@@ -209,15 +210,18 @@ std::vector<T*> findTokensSkipDeadAndUnevaluatedCode(const Library& library,
209210
const std::function<std::vector<MathLib::bigint>(const Token*)>& evaluate)
210211
{
211212
std::vector<T*> result;
213+
214+
std::function<bool(T*)> f = [&](T* tok) {
215+
result.push_back(tok);
216+
return false;
217+
};
218+
212219
(void)findTokensSkipDeadCodeImpl(
213220
library,
214221
start,
215222
end,
216223
pred,
217-
[&](T* tok) {
218-
result.push_back(tok);
219-
return false;
220-
},
224+
std::move(f),
221225
evaluate,
222226
true);
223227
return result;
@@ -234,15 +238,19 @@ template<class T, REQUIRES("T must be a Token class", std::is_convertible<T*, co
234238
T* findTokenSkipDeadCode(const Library& library, T* start, const Token* end, const std::function<bool(const Token*)>& pred, const std::function<std::vector<MathLib::bigint>(const Token*)>& evaluate)
235239
{
236240
T* result = nullptr;
241+
242+
std::function<bool(T*)> f = [&](T* tok)
243+
{
244+
result = tok;
245+
return true;
246+
};
247+
237248
(void)findTokensSkipDeadCodeImpl(
238249
library,
239250
start,
240251
end,
241252
pred,
242-
[&](T* tok) {
243-
result = tok;
244-
return true;
245-
},
253+
std::move(f),
246254
evaluate,
247255
false);
248256
return result;

0 commit comments

Comments
 (0)