diff --git a/src/init.cpp b/src/init.cpp --- a/src/init.cpp +++ b/src/init.cpp @@ -51,7 +51,6 @@ #include #include #include -#include #include #include @@ -1904,9 +1903,9 @@ // Start the lightweight task scheduler thread CScheduler::Function serviceLoop = - boost::bind(&CScheduler::serviceQueue, &scheduler); - threadGroup.create_thread(boost::bind(&TraceThread, - "scheduler", serviceLoop)); + std::bind(&CScheduler::serviceQueue, &scheduler); + threadGroup.create_thread(std::bind(&TraceThread, + "scheduler", serviceLoop)); GetMainSignals().RegisterBackgroundSignalScheduler(scheduler); GetMainSignals().RegisterWithMempoolSignals(g_mempool); @@ -2390,7 +2389,7 @@ } threadGroup.create_thread( - boost::bind(&ThreadImport, std::ref(config), vImportFiles)); + std::bind(&ThreadImport, std::ref(config), vImportFiles)); // Wait for genesis block to be processed { diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -1254,9 +1254,11 @@ void BitcoinGUI::subscribeToCoreSignals() { // Connect signals to client m_handler_message_box = m_node.handleMessageBox( - boost::bind(ThreadSafeMessageBox, this, _1, _2, _3)); + std::bind(ThreadSafeMessageBox, this, std::placeholders::_1, + std::placeholders::_2, std::placeholders::_3)); m_handler_question = m_node.handleQuestion( - boost::bind(ThreadSafeMessageBox, this, _1, _3, _4)); + std::bind(ThreadSafeMessageBox, this, std::placeholders::_1, + std::placeholders::_3, std::placeholders::_4)); } void BitcoinGUI::unsubscribeFromCoreSignals() { diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -236,22 +236,24 @@ void ClientModel::subscribeToCoreSignals() { // Connect signals to client - m_handler_show_progress = - m_node.handleShowProgress(boost::bind(ShowProgress, this, _1, _2)); + m_handler_show_progress = m_node.handleShowProgress(std::bind( + ShowProgress, this, std::placeholders::_1, std::placeholders::_2)); m_handler_notify_num_connections_changed = - m_node.handleNotifyNumConnectionsChanged( - boost::bind(NotifyNumConnectionsChanged, this, _1)); + m_node.handleNotifyNumConnectionsChanged(std::bind( + NotifyNumConnectionsChanged, this, std::placeholders::_1)); m_handler_notify_network_active_changed = m_node.handleNotifyNetworkActiveChanged( - boost::bind(NotifyNetworkActiveChanged, this, _1)); + std::bind(NotifyNetworkActiveChanged, this, std::placeholders::_1)); m_handler_notify_alert_changed = - m_node.handleNotifyAlertChanged(boost::bind(NotifyAlertChanged, this)); + m_node.handleNotifyAlertChanged(std::bind(NotifyAlertChanged, this)); m_handler_banned_list_changed = - m_node.handleBannedListChanged(boost::bind(BannedListChanged, this)); - m_handler_notify_block_tip = m_node.handleNotifyBlockTip( - boost::bind(BlockTipChanged, this, _1, _2, _3, _4, false)); - m_handler_notify_header_tip = m_node.handleNotifyHeaderTip( - boost::bind(BlockTipChanged, this, _1, _2, _3, _4, true)); + m_node.handleBannedListChanged(std::bind(BannedListChanged, this)); + m_handler_notify_block_tip = m_node.handleNotifyBlockTip(std::bind( + BlockTipChanged, this, std::placeholders::_1, std::placeholders::_2, + std::placeholders::_3, std::placeholders::_4, false)); + m_handler_notify_header_tip = m_node.handleNotifyHeaderTip(std::bind( + BlockTipChanged, this, std::placeholders::_1, std::placeholders::_2, + std::placeholders::_3, std::placeholders::_4, true)); } void ClientModel::unsubscribeFromCoreSignals() { diff --git a/src/qt/splashscreen.cpp b/src/qt/splashscreen.cpp --- a/src/qt/splashscreen.cpp +++ b/src/qt/splashscreen.cpp @@ -192,17 +192,19 @@ #ifdef ENABLE_WALLET void SplashScreen::ConnectWallet(std::unique_ptr wallet) { m_connected_wallet_handlers.emplace_back(wallet->handleShowProgress( - boost::bind(ShowProgress, this, _1, _2, false))); + std::bind(ShowProgress, this, std::placeholders::_1, + std::placeholders::_2, false))); m_connected_wallets.emplace_back(std::move(wallet)); } #endif void SplashScreen::subscribeToCoreSignals() { // Connect signals to client - m_handler_init_message = - m_node.handleInitMessage(boost::bind(InitMessage, this, _1)); - m_handler_show_progress = - m_node.handleShowProgress(boost::bind(ShowProgress, this, _1, _2, _3)); + m_handler_init_message = m_node.handleInitMessage( + std::bind(InitMessage, this, std::placeholders::_1)); + m_handler_show_progress = m_node.handleShowProgress( + std::bind(ShowProgress, this, std::placeholders::_1, + std::placeholders::_2, std::placeholders::_3)); #ifdef ENABLE_WALLET m_handler_load_wallet = m_node.handleLoadWallet( [this](std::unique_ptr wallet) { diff --git a/src/qt/transactiontablemodel.cpp b/src/qt/transactiontablemodel.cpp --- a/src/qt/transactiontablemodel.cpp +++ b/src/qt/transactiontablemodel.cpp @@ -757,9 +757,11 @@ // Connect signals to wallet m_handler_transaction_changed = walletModel->wallet().handleTransactionChanged( - boost::bind(NotifyTransactionChanged, this, _1, _2)); - m_handler_show_progress = walletModel->wallet().handleShowProgress( - boost::bind(ShowProgress, this, _1, _2)); + std::bind(NotifyTransactionChanged, this, std::placeholders::_1, + std::placeholders::_2)); + m_handler_show_progress = + walletModel->wallet().handleShowProgress(std::bind( + ShowProgress, this, std::placeholders::_1, std::placeholders::_2)); } void TransactionTableModel::unsubscribeFromCoreSignals() { diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp --- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -390,15 +390,18 @@ void WalletModel::subscribeToCoreSignals() { // Connect signals to wallet m_handler_status_changed = m_wallet->handleStatusChanged( - boost::bind(&NotifyKeyStoreStatusChanged, this)); + std::bind(&NotifyKeyStoreStatusChanged, this)); m_handler_address_book_changed = m_wallet->handleAddressBookChanged( - boost::bind(NotifyAddressBookChanged, this, _1, _2, _3, _4, _5)); + std::bind(NotifyAddressBookChanged, this, std::placeholders::_1, + std::placeholders::_2, std::placeholders::_3, + std::placeholders::_4, std::placeholders::_5)); m_handler_transaction_changed = m_wallet->handleTransactionChanged( - boost::bind(NotifyTransactionChanged, this, _1, _2)); - m_handler_show_progress = - m_wallet->handleShowProgress(boost::bind(ShowProgress, this, _1, _2)); + std::bind(NotifyTransactionChanged, this, std::placeholders::_1, + std::placeholders::_2)); + m_handler_show_progress = m_wallet->handleShowProgress(std::bind( + ShowProgress, this, std::placeholders::_1, std::placeholders::_2)); m_handler_watch_only_changed = m_wallet->handleWatchOnlyChanged( - boost::bind(NotifyWatchonlyChanged, this, _1)); + std::bind(NotifyWatchonlyChanged, this, std::placeholders::_1)); } void WalletModel::unsubscribeFromCoreSignals() { diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -20,7 +20,6 @@ #include #include -#include #include #include // for unique_ptr diff --git a/src/test/scheduler_tests.cpp b/src/test/scheduler_tests.cpp --- a/src/test/scheduler_tests.cpp +++ b/src/test/scheduler_tests.cpp @@ -8,7 +8,6 @@ #include -#include #include #include @@ -27,8 +26,8 @@ boost::chrono::system_clock::time_point::min(); if (rescheduleTime != noTime) { CScheduler::Function f = - boost::bind(µTask, std::ref(s), std::ref(mutex), - std::ref(counter), -delta + 1, noTime); + std::bind(µTask, std::ref(s), std::ref(mutex), + std::ref(counter), -delta + 1, noTime); s.schedule(f, rescheduleTime); } } @@ -79,10 +78,10 @@ boost::chrono::system_clock::time_point tReschedule = now + boost::chrono::microseconds(500 + randomMsec(rng)); int whichCounter = zeroToNine(rng); - CScheduler::Function f = boost::bind( - µTask, std::ref(microTasks), - std::ref(counterMutex[whichCounter]), - std::ref(counter[whichCounter]), randomDelta(rng), tReschedule); + CScheduler::Function f = std::bind(µTask, std::ref(microTasks), + std::ref(counterMutex[whichCounter]), + std::ref(counter[whichCounter]), + randomDelta(rng), tReschedule); microTasks.schedule(f, t); } nTasks = microTasks.getQueueInfo(first, last); @@ -95,7 +94,7 @@ boost::thread_group microThreads; for (int i = 0; i < 5; i++) { microThreads.create_thread( - boost::bind(&CScheduler::serviceQueue, µTasks)); + std::bind(&CScheduler::serviceQueue, µTasks)); } MicroSleep(600); @@ -104,7 +103,7 @@ // More threads and more tasks: for (int i = 0; i < 5; i++) { microThreads.create_thread( - boost::bind(&CScheduler::serviceQueue, µTasks)); + std::bind(&CScheduler::serviceQueue, µTasks)); } for (int i = 0; i < 100; i++) { @@ -113,10 +112,10 @@ boost::chrono::system_clock::time_point tReschedule = now + boost::chrono::microseconds(500 + randomMsec(rng)); int whichCounter = zeroToNine(rng); - CScheduler::Function f = boost::bind( - µTask, std::ref(microTasks), - std::ref(counterMutex[whichCounter]), - std::ref(counter[whichCounter]), randomDelta(rng), tReschedule); + CScheduler::Function f = std::bind(µTask, std::ref(microTasks), + std::ref(counterMutex[whichCounter]), + std::ref(counter[whichCounter]), + randomDelta(rng), tReschedule); microTasks.schedule(f, t); } @@ -195,8 +194,7 @@ // if they don't we'll get out of order behaviour boost::thread_group threads; for (int i = 0; i < 5; ++i) { - threads.create_thread( - boost::bind(&CScheduler::serviceQueue, &scheduler)); + threads.create_thread(std::bind(&CScheduler::serviceQueue, &scheduler)); } // these are not atomic, if SinglethreadedSchedulerClient prevents diff --git a/src/test/test_bitcoin.cpp b/src/test/test_bitcoin.cpp --- a/src/test/test_bitcoin.cpp +++ b/src/test/test_bitcoin.cpp @@ -95,8 +95,7 @@ // We have to run a scheduler thread to prevent ActivateBestChain // from blocking due to queue overrun. - threadGroup.create_thread( - boost::bind(&CScheduler::serviceQueue, &scheduler)); + threadGroup.create_thread(std::bind(&CScheduler::serviceQueue, &scheduler)); GetMainSignals().RegisterBackgroundSignalScheduler(scheduler); g_mempool.setSanityCheck(1.0); diff --git a/src/test/transaction_tests.cpp b/src/test/transaction_tests.cpp --- a/src/test/transaction_tests.cpp +++ b/src/test/transaction_tests.cpp @@ -470,8 +470,8 @@ CCheckQueueControl control(&scriptcheckqueue); for (int i = 0; i < 20; i++) { - threadGroup.create_thread(boost::bind( - &CCheckQueue::Thread, boost::ref(scriptcheckqueue))); + threadGroup.create_thread(std::bind(&CCheckQueue::Thread, + std::ref(scriptcheckqueue))); } std::vector coins; diff --git a/src/torcontrol.cpp b/src/torcontrol.cpp --- a/src/torcontrol.cpp +++ b/src/torcontrol.cpp @@ -15,7 +15,6 @@ #include #include #include -#include #include #include @@ -517,8 +516,10 @@ } // Start connection attempts immediately if (!conn.Connect(_target, - boost::bind(&TorController::connected_cb, this, _1), - boost::bind(&TorController::disconnected_cb, this, _1))) { + std::bind(&TorController::connected_cb, this, + std::placeholders::_1), + std::bind(&TorController::disconnected_cb, this, + std::placeholders::_1))) { LogPrintf("tor: Initiating connection to Tor control port %s failed\n", _target); } @@ -609,7 +610,8 @@ // the shutdown sequence some day. _conn.Command(strprintf("ADD_ONION %s Port=%i,127.0.0.1:%i", private_key, GetListenPort(), GetListenPort()), - boost::bind(&TorController::add_onion_cb, this, _1, _2)); + std::bind(&TorController::add_onion_cb, this, + std::placeholders::_1, std::placeholders::_2)); } else { LogPrintf("tor: Authentication failed\n"); } @@ -682,7 +684,9 @@ std::vector computedClientHash = ComputeResponse( TOR_SAFE_CLIENTKEY, cookie, clientNonce, serverNonce); _conn.Command("AUTHENTICATE " + HexStr(computedClientHash), - boost::bind(&TorController::auth_cb, this, _1, _2)); + std::bind(&TorController::auth_cb, this, + std::placeholders::_1, + std::placeholders::_2)); } else { LogPrintf("tor: Invalid reply to AUTHCHALLENGE\n"); } @@ -740,17 +744,19 @@ LogPrint(BCLog::TOR, "tor: Using HASHEDPASSWORD authentication\n"); boost::replace_all(torpassword, "\"", "\\\""); - _conn.Command( - "AUTHENTICATE \"" + torpassword + "\"", - boost::bind(&TorController::auth_cb, this, _1, _2)); + _conn.Command("AUTHENTICATE \"" + torpassword + "\"", + std::bind(&TorController::auth_cb, this, + std::placeholders::_1, + std::placeholders::_2)); } else { LogPrintf("tor: Password provided with -torpassword, but " "HASHEDPASSWORD authentication is not available\n"); } } else if (methods.count("NULL")) { LogPrint(BCLog::TOR, "tor: Using NULL authentication\n"); - _conn.Command("AUTHENTICATE", - boost::bind(&TorController::auth_cb, this, _1, _2)); + _conn.Command("AUTHENTICATE", std::bind(&TorController::auth_cb, + this, std::placeholders::_1, + std::placeholders::_2)); } else if (methods.count("SAFECOOKIE")) { // Cookie: hexdump -e '32/1 "%02x""\n"' ~/.tor/control_auth_cookie LogPrint(BCLog::TOR, @@ -762,14 +768,16 @@ if (status_cookie.first && status_cookie.second.size() == TOR_COOKIE_SIZE) { // _conn.Command("AUTHENTICATE " + HexStr(status_cookie.second), - // boost::bind(&TorController::auth_cb, this, _1, _2)); + // std::bind(&TorController::auth_cb, this, + // std::placeholders::_1, std::placeholders::_2)); cookie = std::vector(status_cookie.second.begin(), status_cookie.second.end()); clientNonce = std::vector(TOR_NONCE_SIZE, 0); GetRandBytes(&clientNonce[0], TOR_NONCE_SIZE); _conn.Command("AUTHCHALLENGE SAFECOOKIE " + HexStr(clientNonce), - boost::bind(&TorController::authchallenge_cb, - this, _1, _2)); + std::bind(&TorController::authchallenge_cb, this, + std::placeholders::_1, + std::placeholders::_2)); } else { if (status_cookie.first) { LogPrintf("tor: Authentication cookie %s is not exactly %i " @@ -797,9 +805,10 @@ reconnect_timeout = RECONNECT_TIMEOUT_START; // First send a PROTOCOLINFO command to figure out what authentication is // expected - if (!_conn.Command( - "PROTOCOLINFO 1", - boost::bind(&TorController::protocolinfo_cb, this, _1, _2))) { + if (!_conn.Command("PROTOCOLINFO 1", + std::bind(&TorController::protocolinfo_cb, this, + std::placeholders::_1, + std::placeholders::_2))) { LogPrintf("tor: Error sending initial protocolinfo command\n"); } } @@ -831,8 +840,10 @@ * be restarting. */ if (!conn.Connect(target, - boost::bind(&TorController::connected_cb, this, _1), - boost::bind(&TorController::disconnected_cb, this, _1))) { + std::bind(&TorController::connected_cb, this, + std::placeholders::_1), + std::bind(&TorController::disconnected_cb, this, + std::placeholders::_1))) { LogPrintf( "tor: Re-initiating connection to Tor control port %s failed\n", target); diff --git a/src/validation.cpp b/src/validation.cpp --- a/src/validation.cpp +++ b/src/validation.cpp @@ -2323,7 +2323,8 @@ public: explicit ConnectTrace(CTxMemPool &_pool) : blocksConnected(1), pool(_pool) { m_connNotifyEntryRemoved = pool.NotifyEntryRemoved.connect( - boost::bind(&ConnectTrace::NotifyEntryRemoved, this, _1, _2)); + std::bind(&ConnectTrace::NotifyEntryRemoved, this, + std::placeholders::_1, std::placeholders::_2)); } void BlockConnected(CBlockIndex *pindex, diff --git a/src/validationinterface.cpp b/src/validationinterface.cpp --- a/src/validationinterface.cpp +++ b/src/validationinterface.cpp @@ -96,8 +96,9 @@ void CMainSignals::RegisterWithMempoolSignals(CTxMemPool &pool) { g_connNotifyEntryRemoved.emplace( - &pool, pool.NotifyEntryRemoved.connect(boost::bind( - &CMainSignals::MempoolEntryRemoved, this, _1, _2))); + &pool, pool.NotifyEntryRemoved.connect( + std::bind(&CMainSignals::MempoolEntryRemoved, this, + std::placeholders::_1, std::placeholders::_2))); } void CMainSignals::UnregisterWithMempoolSignals(CTxMemPool &pool) { @@ -111,30 +112,37 @@ void RegisterValidationInterface(CValidationInterface *pwalletIn) { ValidationInterfaceConnections &conns = g_signals.m_internals->m_connMainSignals[pwalletIn]; - conns.UpdatedBlockTip = - g_signals.m_internals->UpdatedBlockTip.connect(boost::bind( - &CValidationInterface::UpdatedBlockTip, pwalletIn, _1, _2, _3)); + conns.UpdatedBlockTip = g_signals.m_internals->UpdatedBlockTip.connect( + std::bind(&CValidationInterface::UpdatedBlockTip, pwalletIn, + std::placeholders::_1, std::placeholders::_2, + std::placeholders::_3)); conns.TransactionAddedToMempool = - g_signals.m_internals->TransactionAddedToMempool.connect(boost::bind( - &CValidationInterface::TransactionAddedToMempool, pwalletIn, _1)); - conns.BlockConnected = - g_signals.m_internals->BlockConnected.connect(boost::bind( - &CValidationInterface::BlockConnected, pwalletIn, _1, _2, _3)); + g_signals.m_internals->TransactionAddedToMempool.connect( + std::bind(&CValidationInterface::TransactionAddedToMempool, + pwalletIn, std::placeholders::_1)); + conns.BlockConnected = g_signals.m_internals->BlockConnected.connect( + std::bind(&CValidationInterface::BlockConnected, pwalletIn, + std::placeholders::_1, std::placeholders::_2, + std::placeholders::_3)); conns.BlockDisconnected = g_signals.m_internals->BlockDisconnected.connect( - boost::bind(&CValidationInterface::BlockDisconnected, pwalletIn, _1)); + std::bind(&CValidationInterface::BlockDisconnected, pwalletIn, + std::placeholders::_1)); conns.TransactionRemovedFromMempool = g_signals.m_internals->TransactionRemovedFromMempool.connect( - boost::bind(&CValidationInterface::TransactionRemovedFromMempool, - pwalletIn, _1)); + std::bind(&CValidationInterface::TransactionRemovedFromMempool, + pwalletIn, std::placeholders::_1)); conns.ChainStateFlushed = g_signals.m_internals->ChainStateFlushed.connect( - boost::bind(&CValidationInterface::ChainStateFlushed, pwalletIn, _1)); - conns.Broadcast = g_signals.m_internals->Broadcast.connect(boost::bind( - &CValidationInterface::ResendWalletTransactions, pwalletIn, _1, _2)); + std::bind(&CValidationInterface::ChainStateFlushed, pwalletIn, + std::placeholders::_1)); + conns.Broadcast = g_signals.m_internals->Broadcast.connect( + std::bind(&CValidationInterface::ResendWalletTransactions, pwalletIn, + std::placeholders::_1, std::placeholders::_2)); conns.BlockChecked = g_signals.m_internals->BlockChecked.connect( - boost::bind(&CValidationInterface::BlockChecked, pwalletIn, _1, _2)); - conns.NewPoWValidBlock = - g_signals.m_internals->NewPoWValidBlock.connect(boost::bind( - &CValidationInterface::NewPoWValidBlock, pwalletIn, _1, _2)); + std::bind(&CValidationInterface::BlockChecked, pwalletIn, + std::placeholders::_1, std::placeholders::_2)); + conns.NewPoWValidBlock = g_signals.m_internals->NewPoWValidBlock.connect( + std::bind(&CValidationInterface::NewPoWValidBlock, pwalletIn, + std::placeholders::_1, std::placeholders::_2)); } void UnregisterValidationInterface(CValidationInterface *pwalletIn) { diff --git a/test/lint/lint-boost-dependencies.sh b/test/lint/lint-boost-dependencies.sh --- a/test/lint/lint-boost-dependencies.sh +++ b/test/lint/lint-boost-dependencies.sh @@ -15,7 +15,6 @@ boost/algorithm/string/replace.hpp boost/algorithm/string/split.hpp boost/assign/std/vector.hpp - boost/bind.hpp boost/chrono/chrono.hpp boost/date_time/posix_time/posix_time.hpp boost/filesystem.hpp