diff options
author | Tobias Markmann <tm@ayena.de> | 2018-05-07 18:48:01 (GMT) |
---|---|---|
committer | Tobias Markmann <tm@ayena.de> | 2018-05-07 18:48:01 (GMT) |
commit | d9994a01bca43aab08fc67b789e71d28672c6ba1 (patch) | |
tree | bd842012bd552b953af1f52cff893a032da3a4de | |
parent | e9f6129a4ce5db25bcb6de47be94ee89357713d0 (diff) | |
download | swift-d9994a01bca43aab08fc67b789e71d28672c6ba1.zip swift-d9994a01bca43aab08fc67b789e71d28672c6ba1.tar.bz2 |
Replace boost::lambda with C++11 lambdas
Test-Information:
Builds on macOS 10.13.4 with clang trunk. All unit and
integration tests pass. Produces fewer warnings with clang
trunk (previously reported marked-unused-but-used warnings).
Change-Id: I849d764537cfbc380155e87b033dc5e517b3c342
-rw-r--r-- | Sluift/client.cpp | 9 | ||||
-rw-r--r-- | Sluift/component.cpp | 9 | ||||
-rw-r--r-- | Swift/Controllers/ContactSuggester.cpp | 11 | ||||
-rw-r--r-- | Swift/QtUI/QtStatusWidget.cpp | 12 | ||||
-rw-r--r-- | Swiften/EventLoop/EventLoop.cpp | 11 | ||||
-rw-r--r-- | Swiften/Network/DomainNameServiceQuery.cpp | 10 | ||||
-rw-r--r-- | Swiften/Parser/AttributeMap.cpp | 20 | ||||
-rw-r--r-- | Swiften/Parser/Tree/ParserElement.cpp | 12 |
8 files changed, 38 insertions, 56 deletions
diff --git a/Sluift/client.cpp b/Sluift/client.cpp index ae2f610..ec208bc 100644 --- a/Sluift/client.cpp +++ b/Sluift/client.cpp @@ -1,3 +1,3 @@ /* - * Copyright (c) 2013-2017 Isode Limited. + * Copyright (c) 2013-2018 Isode Limited. * All rights reserved. @@ -7,4 +7,2 @@ #include <boost/assign/list_of.hpp> -#include <boost/lambda/bind.hpp> -#include <boost/lambda/lambda.hpp> @@ -44,3 +42,2 @@ using namespace Swift; -namespace lambda = boost::lambda; @@ -661,3 +658,5 @@ SLUIFT_LUA_FUNCTION(Client, get_next_event) { event = client->getNextEvent( - timeout, lambda::bind(&SluiftClient::Event::type, lambda::_1) == *type); + timeout, [&](const SluiftClient::Event& event) { + return event.type == *type; + }); } diff --git a/Sluift/component.cpp b/Sluift/component.cpp index df96d43..f3c2e37 100644 --- a/Sluift/component.cpp +++ b/Sluift/component.cpp @@ -1,3 +1,3 @@ /* - * Copyright (c) 2014-2016 Isode Limited. + * Copyright (c) 2014-2018 Isode Limited. * All rights reserved. @@ -7,4 +7,2 @@ #include <boost/assign/list_of.hpp> -#include <boost/lambda/bind.hpp> -#include <boost/lambda/lambda.hpp> @@ -43,3 +41,2 @@ using namespace Swift; -namespace lambda = boost::lambda; @@ -435,3 +432,5 @@ SLUIFT_LUA_FUNCTION(Component, get_next_event) { event = component->getNextEvent( - timeout, lambda::bind(&SluiftComponent::Event::type, lambda::_1) == *type); + timeout, [&](const SluiftComponent::Event& event) { + return event.type == *type; + }); } diff --git a/Swift/Controllers/ContactSuggester.cpp b/Swift/Controllers/ContactSuggester.cpp index eb27ed4..4b621db 100644 --- a/Swift/Controllers/ContactSuggester.cpp +++ b/Swift/Controllers/ContactSuggester.cpp @@ -7,3 +7,3 @@ /* - * Copyright (c) 2014-2016 Isode Limited. + * Copyright (c) 2014-2018 Isode Limited. * All rights reserved. @@ -21,4 +21,2 @@ #include <boost/bind.hpp> -#include <boost/lambda/bind.hpp> -#include <boost/lambda/lambda.hpp> @@ -29,4 +27,2 @@ -namespace lambda = boost::lambda; - namespace Swift { @@ -62,4 +58,5 @@ std::vector<Contact::ref> ContactSuggester::getSuggestions(const std::string& se results.erase(std::unique(results.begin(), results.end(), Contact::equalityPredicate), results.end()); - results.erase(std::remove_if(results.begin(), results.end(), !lambda::bind(&matchContact, search, lambda::_1)), - results.end()); + results.erase(std::remove_if(results.begin(), results.end(), [&](const Contact::ref contact) { + return !matchContact(search, contact); + }), results.end()); std::sort(results.begin(), results.end(), boost::bind(&Contact::sortPredicate, _1, _2, search)); diff --git a/Swift/QtUI/QtStatusWidget.cpp b/Swift/QtUI/QtStatusWidget.cpp index b175e5c..5e2ba5f 100644 --- a/Swift/QtUI/QtStatusWidget.cpp +++ b/Swift/QtUI/QtStatusWidget.cpp @@ -1,3 +1,3 @@ /* - * Copyright (c) 2010-2016 Isode Limited. + * Copyright (c) 2010-2018 Isode Limited. * All rights reserved. @@ -10,5 +10,2 @@ -#include <boost/lambda/bind.hpp> -#include <boost/lambda/lambda.hpp> - #include <QApplication> @@ -34,4 +31,2 @@ -namespace lambda = boost::lambda; - namespace Swift { @@ -155,4 +150,5 @@ void QtStatusWidget::generateList() { for (const auto& savedStatus : previousStatuses) { - if (savedStatus.first.empty() || std::find_if(allTypes_.begin(), allTypes_.end(), - savedStatus.second == lambda::_1 && savedStatus.first == lambda::bind(&statusShowTypeToFriendlyName, lambda::_1)) != allTypes_.end()) { + if (savedStatus.first.empty() || std::find_if(allTypes_.begin(), allTypes_.end(), [&](StatusShow::Type type) { + return (savedStatus.second == type) && (savedStatus.first == statusShowTypeToFriendlyName(type)); + }) != allTypes_.end()) { continue; diff --git a/Swiften/EventLoop/EventLoop.cpp b/Swiften/EventLoop/EventLoop.cpp index 186616f..f6af699 100644 --- a/Swiften/EventLoop/EventLoop.cpp +++ b/Swiften/EventLoop/EventLoop.cpp @@ -1,3 +1,3 @@ /* - * Copyright (c) 2010-2016 Isode Limited. + * Copyright (c) 2010-2018 Isode Limited. * All rights reserved. @@ -12,5 +12,2 @@ -#include <boost/bind.hpp> -#include <boost/lambda/bind.hpp> -#include <boost/lambda/lambda.hpp> #include <boost/optional.hpp> @@ -19,4 +16,2 @@ -namespace lambda = boost::lambda; - namespace Swift { @@ -98,3 +93,5 @@ void EventLoop::removeEventsFromOwner(std::shared_ptr<EventOwner> owner) { - events_.remove_if(lambda::bind(&Event::owner, lambda::_1) == owner); + events_.remove_if([&](const Event& event) { + return event.owner == owner; + }); } diff --git a/Swiften/Network/DomainNameServiceQuery.cpp b/Swiften/Network/DomainNameServiceQuery.cpp index 0c6c543..548c837 100644 --- a/Swiften/Network/DomainNameServiceQuery.cpp +++ b/Swiften/Network/DomainNameServiceQuery.cpp @@ -13,4 +13,2 @@ -#include <boost/lambda/bind.hpp> -#include <boost/lambda/lambda.hpp> #include <boost/numeric/conversion/cast.hpp> @@ -20,3 +18,2 @@ using namespace Swift; -namespace lambda = boost::lambda; @@ -44,5 +41,6 @@ void DomainNameServiceQuery::sortResults(std::vector<DomainNameServiceQuery::Res std::vector<int> weights; - std::transform(i, next, std::back_inserter(weights), - /* easy hack to account for '0' weights getting at least some weight */ - lambda::bind(&Result::weight, lambda::_1) + 1); + std::transform(i, next, std::back_inserter(weights), [](const DomainNameServiceQuery::Result& result) { + /* easy hack to account for '0' weights getting at least some weight */ + return result.weight + 1; + }); for (int j = 0; j < boost::numeric_cast<int>(weights.size() - 1); ++j) { diff --git a/Swiften/Parser/AttributeMap.cpp b/Swiften/Parser/AttributeMap.cpp index c112d52..f6767de 100644 --- a/Swiften/Parser/AttributeMap.cpp +++ b/Swiften/Parser/AttributeMap.cpp @@ -1,3 +1,3 @@ /* - * Copyright (c) 2011-2016 Isode Limited. + * Copyright (c) 2011-2018 Isode Limited. * All rights reserved. @@ -10,4 +10,2 @@ -#include <boost/lambda/bind.hpp> -#include <boost/lambda/lambda.hpp> #include <boost/optional.hpp> @@ -15,3 +13,2 @@ using namespace Swift; -namespace lambda = boost::lambda; @@ -21,4 +18,5 @@ AttributeMap::AttributeMap() { std::string AttributeMap::getAttribute(const std::string& attribute, const std::string& ns) const { - AttributeValueMap::const_iterator i = std::find_if(attributes.begin(), attributes.end(), - lambda::bind(&AttributeMap::Entry::getAttribute, lambda::_1) == Attribute(attribute, ns)); + const auto i = std::find_if(attributes.begin(), attributes.end(), [&](const Entry& entry) { + return entry.getAttribute() == Attribute(attribute, ns); + }); if (i == attributes.end()) { @@ -32,4 +30,5 @@ std::string AttributeMap::getAttribute(const std::string& attribute, const std:: bool AttributeMap::getBoolAttribute(const std::string& attribute, bool defaultValue) const { - AttributeValueMap::const_iterator i = std::find_if(attributes.begin(), attributes.end(), - lambda::bind(&AttributeMap::Entry::getAttribute, lambda::_1) == Attribute(attribute, "")); + const auto i = std::find_if(attributes.begin(), attributes.end(), [&](const Entry& entry) { + return entry.getAttribute() == Attribute(attribute, ""); + }); if (i == attributes.end()) { @@ -43,4 +42,5 @@ bool AttributeMap::getBoolAttribute(const std::string& attribute, bool defaultVa boost::optional<std::string> AttributeMap::getAttributeValue(const std::string& attribute) const { - AttributeValueMap::const_iterator i = std::find_if(attributes.begin(), attributes.end(), - lambda::bind(&AttributeMap::Entry::getAttribute, lambda::_1) == Attribute(attribute, "")); + const auto i = std::find_if(attributes.begin(), attributes.end(), [&](const Entry& entry) { + return entry.getAttribute() == Attribute(attribute, ""); + }); if (i == attributes.end()) { diff --git a/Swiften/Parser/Tree/ParserElement.cpp b/Swiften/Parser/Tree/ParserElement.cpp index 5415945..988bc13 100644 --- a/Swiften/Parser/Tree/ParserElement.cpp +++ b/Swiften/Parser/Tree/ParserElement.cpp @@ -1,3 +1,3 @@ /* - * Copyright (c) 2011-2016 Isode Limited. + * Copyright (c) 2011-2018 Isode Limited. * All rights reserved. @@ -9,9 +9,4 @@ -#include <boost/lambda/bind.hpp> -#include <boost/lambda/lambda.hpp> - #include <Swiften/Parser/Tree/NullParserElement.h> -namespace lambda = boost::lambda; - namespace Swift { @@ -36,4 +31,5 @@ std::vector<ParserElement::ref> ParserElement::getChildren(const std::string& na std::vector<ParserElement::ref> result; - std::remove_copy_if(children_.begin(), children_.end(), std::back_inserter(result), - lambda::bind(&ParserElement::getName, *lambda::_1) != name || lambda::bind(&ParserElement::getNamespace, *lambda::_1) != xmlns); + std::remove_copy_if(children_.begin(), children_.end(), std::back_inserter(result), [&](const ParserElement::ref& element) { + return (element->getName() != name) || (element->getNamespace() != xmlns); + }); return result; |