diff --git a/src/AbstractCommand.cc b/src/AbstractCommand.cc index bb078495..5736180a 100644 --- a/src/AbstractCommand.cc +++ b/src/AbstractCommand.cc @@ -469,7 +469,7 @@ void AbstractCommand::onAbort() { std::vector uris; uris.reserve(res.size()); std::transform(res.begin(), res.end(), std::back_inserter(uris), - std::mem_fun_ref(&URIResult::getURI)); + std::mem_fn(&URIResult::getURI)); A2_LOG_DEBUG(fmt("CUID#%" PRId64 " - %lu URIs found.", getCuid(), static_cast(uris.size()))); diff --git a/src/AdaptiveURISelector.cc b/src/AdaptiveURISelector.cc index cbc84057..5ee353c6 100644 --- a/src/AdaptiveURISelector.cc +++ b/src/AdaptiveURISelector.cc @@ -106,7 +106,7 @@ void AdaptiveURISelector::mayRetryWithIncreasedTimeout(FileEntry* fileEntry) std::deque timeouts; fileEntry->extractURIResult(timeouts, error_code::TIME_OUT); std::transform(timeouts.begin(), timeouts.end(), std::back_inserter(uris), - std::mem_fun_ref(&URIResult::getURI)); + std::mem_fn(&URIResult::getURI)); if(A2_LOG_DEBUG_ENABLED) { for(std::deque::const_iterator i = uris.begin(), diff --git a/src/BtLeecherStateChoke.cc b/src/BtLeecherStateChoke.cc index 52a9139f..9f8ca9dc 100644 --- a/src/BtLeecherStateChoke.cc +++ b/src/BtLeecherStateChoke.cc @@ -144,7 +144,7 @@ void BtLeecherStateChoke::plannedOptimisticUnchoke (std::vector& peerEntries) { std::for_each(peerEntries.begin(), peerEntries.end(), - std::mem_fun_ref(&PeerEntry::disableOptUnchoking)); + std::mem_fn(&PeerEntry::disableOptUnchoking)); std::vector::iterator i = std::partition(peerEntries.begin(), peerEntries.end(), @@ -162,7 +162,7 @@ void BtLeecherStateChoke::regularUnchoke(std::vector& peerEntries) { std::vector::iterator rest = std::partition(peerEntries.begin(), peerEntries.end(), - std::mem_fun_ref(&PeerEntry::isRegularUnchoker)); + std::mem_fn(&PeerEntry::isRegularUnchoker)); std::sort(peerEntries.begin(), rest); diff --git a/src/BtSeederStateChoke.cc b/src/BtSeederStateChoke.cc index 54c936f3..b247ed08 100644 --- a/src/BtSeederStateChoke.cc +++ b/src/BtSeederStateChoke.cc @@ -135,7 +135,7 @@ void BtSeederStateChoke::unchoke if(round_ < 2) { std::for_each(peers.begin(), peers.end(), - std::mem_fun_ref(&PeerEntry::disableOptUnchoking)); + std::mem_fn(&PeerEntry::disableOptUnchoking)); if(r != peers.end()) { std::random_shuffle(r, peers.end(), *SimpleRandomizer::getInstance()); diff --git a/src/CookieStorage.cc b/src/CookieStorage.cc index f5819299..e9353091 100644 --- a/src/CookieStorage.cc +++ b/src/CookieStorage.cc @@ -111,6 +111,7 @@ void CookieStorage::DomainEntry::findCookie bool CookieStorage::DomainEntry::addCookie(const Cookie& cookie, time_t now) { + using namespace std::placeholders; setLastAccessTime(now); std::deque::iterator i = std::find(cookies_.begin(), cookies_.end(), cookie); @@ -121,8 +122,7 @@ bool CookieStorage::DomainEntry::addCookie(const Cookie& cookie, time_t now) if(cookies_.size() >= CookieStorage::MAX_COOKIE_PER_DOMAIN) { cookies_.erase (std::remove_if(cookies_.begin(), cookies_.end(), - std::bind2nd - (std::mem_fun_ref(&Cookie::isExpired), now)), + std::bind(&Cookie::isExpired, _1, now)), cookies_.end()); if(cookies_.size() >= CookieStorage::MAX_COOKIE_PER_DOMAIN) { std::deque::iterator m = std::min_element diff --git a/src/DHTMessageDispatcherImpl.cc b/src/DHTMessageDispatcherImpl.cc index 8cdf4c52..723290ea 100644 --- a/src/DHTMessageDispatcherImpl.cc +++ b/src/DHTMessageDispatcherImpl.cc @@ -103,10 +103,7 @@ DHTMessageDispatcherImpl::sendMessage void DHTMessageDispatcherImpl::sendMessages() { - // TODO I can't use bind1st and mem_fun here because bind1st cannot bind a - // function which takes a reference as an argument.. - std::deque >::iterator itr = - messageQueue_.begin(); + auto itr = messageQueue_.begin(); for(; itr != messageQueue_.end(); ++itr) { if(!sendMessage(*itr)) { break; diff --git a/src/DefaultPieceStorage.cc b/src/DefaultPieceStorage.cc index cef39f04..1c400b33 100644 --- a/src/DefaultPieceStorage.cc +++ b/src/DefaultPieceStorage.cc @@ -235,8 +235,9 @@ namespace { void unsetExcludedIndexes(BitfieldMan& bitfield, const std::vector& excludedIndexes) { + using namespace std::placeholders; std::for_each(excludedIndexes.begin(), excludedIndexes.end(), - std::bind1st(std::mem_fun(&BitfieldMan::unsetBit), &bitfield)); + std::bind(&BitfieldMan::unsetBit, &bitfield, _1)); } } // namespace diff --git a/src/Event.h b/src/Event.h index 249b2ce5..006724da 100644 --- a/src/Event.h +++ b/src/Event.h @@ -290,15 +290,12 @@ public: void processEvents(int events) { + using namespace std::placeholders; std::for_each(commandEvents_.begin(), commandEvents_.end(), - std::bind2nd(std::mem_fun_ref - (&CommandEvent::processEvents), - events)); + std::bind(&CommandEvent::processEvents, _1, events)); #ifdef ENABLE_ASYNC_DNS std::for_each(adnsEvents_.begin(), adnsEvents_.end(), - std::bind2nd(std::mem_fun_ref - (&ADNSEvent::processEvents), - events)); + std::bind(&ADNSEvent::processEvents, _1, events)); #endif // ENABLE_ASYNC_DNS } }; diff --git a/src/FileEntry.cc b/src/FileEntry.cc index e3be45eb..364b0cf4 100644 --- a/src/FileEntry.cc +++ b/src/FileEntry.cc @@ -403,7 +403,7 @@ void FileEntry::reuseUri(const std::vector& ignore) std::vector errorUris(uriResults_.size()); std::transform(uriResults_.begin(), uriResults_.end(), - errorUris.begin(), std::mem_fun_ref(&URIResult::getURI)); + errorUris.begin(), std::mem_fn(&URIResult::getURI)); std::sort(errorUris.begin(), errorUris.end()); errorUris.erase(std::unique(errorUris.begin(), errorUris.end()), errorUris.end()); diff --git a/src/RpcMethod.cc b/src/RpcMethod.cc index 19467050..892ba87d 100644 --- a/src/RpcMethod.cc +++ b/src/RpcMethod.cc @@ -119,7 +119,7 @@ void RpcMethod::gatherRequestOption(Option* option, const Dict* optionsDict) { if(optionsDict) { gatherOption(optionsDict->begin(), optionsDict->end(), - std::mem_fun(&OptionHandler::getInitialOption), + std::mem_fn(&OptionHandler::getInitialOption), option, optionParser_); } } @@ -128,7 +128,7 @@ void RpcMethod::gatherChangeableOption(Option* option, const Dict* optionsDict) { if(optionsDict) { gatherOption(optionsDict->begin(), optionsDict->end(), - std::mem_fun(&OptionHandler::getChangeOption), + std::mem_fn(&OptionHandler::getChangeOption), option, optionParser_); } } @@ -139,7 +139,7 @@ void RpcMethod::gatherChangeableOptionForReserved { if(optionsDict) { gatherOption(optionsDict->begin(), optionsDict->end(), - std::mem_fun(&OptionHandler::getChangeOptionForReserved), + std::mem_fn(&OptionHandler::getChangeOptionForReserved), option, optionParser_); } } @@ -149,7 +149,7 @@ void RpcMethod::gatherChangeableGlobalOption { if(optionsDict) { gatherOption(optionsDict->begin(), optionsDict->end(), - std::mem_fun(&OptionHandler::getChangeGlobalOption), + std::mem_fn(&OptionHandler::getChangeGlobalOption), option, optionParser_); } } diff --git a/src/SelectEventPoll.cc b/src/SelectEventPoll.cc index c5682b5b..11a6c156 100644 --- a/src/SelectEventPoll.cc +++ b/src/SelectEventPoll.cc @@ -106,9 +106,9 @@ void SelectEventPoll::SocketEntry::removeCommandEvent } void SelectEventPoll::SocketEntry::processEvents(int events) { + using namespace std::placeholders; std::for_each(commandEvents_.begin(), commandEvents_.end(), - std::bind2nd(std::mem_fun_ref(&CommandEvent::processEvents), - events)); + std::bind(&CommandEvent::processEvents, _1, events)); } int accumulateEvent(int events, const SelectEventPoll::CommandEvent& event) diff --git a/src/aria2api.cc b/src/aria2api.cc index bb5f6967..6a353f70 100644 --- a/src/aria2api.cc +++ b/src/aria2api.cc @@ -220,7 +220,7 @@ void apiGatherRequestOption(Option* option, const KeyVals& options, const std::shared_ptr& optionParser) { apiGatherOption(options.begin(), options.end(), - std::mem_fun(&OptionHandler::getInitialOption), + std::mem_fn(&OptionHandler::getInitialOption), option, optionParser); } } // namespace @@ -230,7 +230,7 @@ void apiGatherChangeableOption(Option* option, const KeyVals& options, const std::shared_ptr& optionParser) { apiGatherOption(options.begin(), options.end(), - std::mem_fun(&OptionHandler::getChangeOption), + std::mem_fn(&OptionHandler::getChangeOption), option, optionParser); } } // namespace @@ -241,7 +241,7 @@ void apiGatherChangeableOptionForReserved const std::shared_ptr& optionParser) { apiGatherOption(options.begin(), options.end(), - std::mem_fun(&OptionHandler::getChangeOptionForReserved), + std::mem_fn(&OptionHandler::getChangeOptionForReserved), option, optionParser); } } // namespace @@ -252,7 +252,7 @@ void apiGatherChangeableGlobalOption const std::shared_ptr& optionParser) { apiGatherOption(options.begin(), options.end(), - std::mem_fun(&OptionHandler::getChangeGlobalOption), + std::mem_fn(&OptionHandler::getChangeGlobalOption), option, optionParser); } } // namespace