1 From fb401094c3d88da14e1b909d786a86c3a68d2199 Mon Sep 17 00:00:00 2001
2 From: Petr Nechaev <petr.nechaev@cogentembedded.com>
3 Date: Mon, 27 Jul 2015 20:34:47 +0300
4 Subject: [PATCH 1/9] Improve backward compatibility with old linaro gcc
7 lib/listplusplus.h | 8 ++++++--
8 plugins/common/jsonprotocol.cpp | 6 +++---
9 plugins/testplugin/testplugin.cpp | 2 +-
10 3 files changed, 10 insertions(+), 6 deletions(-)
12 diff --git a/lib/listplusplus.h b/lib/listplusplus.h
13 index 433d34c..e653615 100644
14 --- a/lib/listplusplus.h
15 +++ b/lib/listplusplus.h
17 template <class T, class V, class Predicate>
18 bool contains(const T & iteratable, V value, Predicate comparator )
20 - return std::any_of(iteratable.begin(), iteratable.end(), [value, &comparator](auto i) { return comparator(value, i); });
21 + for(auto i : iteratable)
23 + if(comparator(value, i))
28 template <class T, class V>
29 bool contains(const T & iteratable, V value)
31 - return contains(iteratable, value, [](auto a, auto b) { return a == b; });
32 + return iteratable.size() > 0 && (std::find(iteratable.begin(), iteratable.end(), value) != iteratable.end());
36 diff --git a/plugins/common/jsonprotocol.cpp b/plugins/common/jsonprotocol.cpp
37 index a534900..43ef8cf 100644
38 --- a/plugins/common/jsonprotocol.cpp
39 +++ b/plugins/common/jsonprotocol.cpp
40 @@ -149,7 +149,7 @@ void amb::AmbRemoteClient::hasJsonMessage(const picojson::value &json)
42 const ListMethodCall::Ptr listMethod = listMethodReply.method();
44 - auto itr = std::find_if(mListCalls.begin(), mListCalls.end(),[&listMethod](auto o)
45 + auto itr = std::find_if(mListCalls.begin(), mListCalls.end(),[&listMethod](ListMethodCall::Ptr o)
47 return o->messageId == listMethod->messageId;
49 @@ -176,7 +176,7 @@ void amb::AmbRemoteClient::hasJsonMessage(const picojson::value &json)
51 GetMethodCall::Ptr getCall = reply.method();
53 - auto itr = std::find_if(mGetMethodCalls.begin(), mGetMethodCalls.end(),[&getCall](auto o)
54 + auto itr = std::find_if(mGetMethodCalls.begin(), mGetMethodCalls.end(),[&getCall](GetMethodCall::Ptr o)
56 return o->messageId == getCall->messageId;
58 @@ -205,7 +205,7 @@ void amb::AmbRemoteClient::hasJsonMessage(const picojson::value &json)
60 auto call = reply.method();
62 - auto itr = std::find_if(mSetMethodCalls.begin(), mSetMethodCalls.end(),[&call](auto o)
63 + auto itr = std::find_if(mSetMethodCalls.begin(), mSetMethodCalls.end(),[&call](SetMethodCall::Ptr o)
65 return o->messageId == call->messageId;
67 diff --git a/plugins/testplugin/testplugin.cpp b/plugins/testplugin/testplugin.cpp
68 index d854d5f..a96cf19 100644
69 --- a/plugins/testplugin/testplugin.cpp
70 +++ b/plugins/testplugin/testplugin.cpp
71 @@ -268,7 +268,7 @@ bool testListPlusPlus()
72 complexList.push_back(complex1);
73 complexList.push_back(complex2);
75 - TEST(contains(complexList, complex1, [](auto a, auto b) { return a.foo == b.foo && a.bar == b.bar; }));
76 + TEST(contains(complexList, complex1, [](Complex a, Complex b) { return a.foo == b.foo && a.bar == b.bar; }));