mirror of
https://github.com/aria2/aria2.git
synced 2025-02-26 08:22:11 +00:00
Use std::mem_fn instead of std::mem_fun
This commit is contained in:
parent
38d4574355
commit
ca329a7ccb
@ -469,7 +469,7 @@ void AbstractCommand::onAbort() {
|
||||
std::vector<std::string> 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<unsigned long int>(uris.size())));
|
||||
|
@ -106,7 +106,7 @@ void AdaptiveURISelector::mayRetryWithIncreasedTimeout(FileEntry* fileEntry)
|
||||
std::deque<URIResult> 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<std::string>::const_iterator i = uris.begin(),
|
||||
|
@ -144,7 +144,7 @@ void BtLeecherStateChoke::plannedOptimisticUnchoke
|
||||
(std::vector<PeerEntry>& peerEntries)
|
||||
{
|
||||
std::for_each(peerEntries.begin(), peerEntries.end(),
|
||||
std::mem_fun_ref(&PeerEntry::disableOptUnchoking));
|
||||
std::mem_fn(&PeerEntry::disableOptUnchoking));
|
||||
|
||||
std::vector<PeerEntry>::iterator i =
|
||||
std::partition(peerEntries.begin(), peerEntries.end(),
|
||||
@ -162,7 +162,7 @@ void BtLeecherStateChoke::regularUnchoke(std::vector<PeerEntry>& peerEntries)
|
||||
{
|
||||
std::vector<PeerEntry>::iterator rest =
|
||||
std::partition(peerEntries.begin(), peerEntries.end(),
|
||||
std::mem_fun_ref(&PeerEntry::isRegularUnchoker));
|
||||
std::mem_fn(&PeerEntry::isRegularUnchoker));
|
||||
|
||||
std::sort(peerEntries.begin(), rest);
|
||||
|
||||
|
@ -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());
|
||||
|
@ -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<Cookie>::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<Cookie>::iterator m = std::min_element
|
||||
|
@ -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<std::shared_ptr<DHTMessageEntry> >::iterator itr =
|
||||
messageQueue_.begin();
|
||||
auto itr = messageQueue_.begin();
|
||||
for(; itr != messageQueue_.end(); ++itr) {
|
||||
if(!sendMessage(*itr)) {
|
||||
break;
|
||||
|
@ -235,8 +235,9 @@ namespace {
|
||||
void unsetExcludedIndexes(BitfieldMan& bitfield,
|
||||
const std::vector<size_t>& 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
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
};
|
||||
|
@ -403,7 +403,7 @@ void FileEntry::reuseUri(const std::vector<std::string>& ignore)
|
||||
|
||||
std::vector<std::string> 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());
|
||||
|
@ -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_);
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -220,7 +220,7 @@ void apiGatherRequestOption(Option* option, const KeyVals& options,
|
||||
const std::shared_ptr<OptionParser>& 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>& 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>& 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>& optionParser)
|
||||
{
|
||||
apiGatherOption(options.begin(), options.end(),
|
||||
std::mem_fun(&OptionHandler::getChangeGlobalOption),
|
||||
std::mem_fn(&OptionHandler::getChangeGlobalOption),
|
||||
option, optionParser);
|
||||
}
|
||||
} // namespace
|
||||
|
Loading…
Reference in New Issue
Block a user