Skip to content

Commit 3e390b8

Browse files
author
Rob Walker
committed
functor instead of std::function
1 parent 8a84cfb commit 3e390b8

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/lib/datamodel/Deque.h

+8-4
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ class Deque
6161
* item->mMe of the match or NULL if no match.
6262
* Mutation of the list during fn() should be avoided
6363
*/
64-
T * Find(std::function<bool(T *)> fn)
64+
template <typename Functor>
65+
T * Find(Functor fn)
6566
{
6667
Deque * next = nullptr;
6768
for (Deque * item = this; next != this; item = next)
@@ -87,7 +88,8 @@ class Deque
8788
* item->mMe of the match or NULL if no match.
8889
* Mutation of the list during fn() should be avoided
8990
*/
90-
T * FindR(std::function<bool(T *)> fn)
91+
template <typename Functor>
92+
T * FindR(Functor fn)
9193
{
9294
Deque * prev = nullptr;
9395
for (Deque * item = mPrev; prev != mPrev; item = prev)
@@ -110,7 +112,8 @@ class Deque
110112
* this item.
111113
* Mutation of the list during fn() should be avoided
112114
*/
113-
void Foreach(std::function<void(T *)> fn)
115+
template <typename Functor>
116+
void Foreach(Functor fn)
114117
{
115118
Deque * next = nullptr;
116119
for (Deque * item = this; next != this; item = next)
@@ -129,7 +132,8 @@ class Deque
129132
* the last item
130133
* Mutation of the list during fn() should be avoided
131134
*/
132-
void ForeachR(std::function<void(T *)> fn)
135+
template <typename Functor>
136+
void ForeachR(Functor fn)
133137
{
134138
Deque * prev = nullptr;
135139
for (Deque * item = mPrev; prev != mPrev; item = prev)

0 commit comments

Comments
 (0)