Merge pull request #3796 from chromatic/1.15.0-remove-boost-function

Replace boost::function with std::function
This commit is contained in:
Old Dip Tracker 2025-04-01 20:30:55 +02:00 committed by GitHub
commit a417f9c984
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 34 additions and 31 deletions

View File

@ -7,7 +7,7 @@
#include <cstdint> // for uint64_t
#include <boost/function.hpp> // for function
#include <functional> // for std::function
#include <boost/preprocessor/cat.hpp> // for BOOST_PP_CAT
#include <boost/preprocessor/stringize.hpp> // for BOOST_PP_STRINGIZE
@ -62,7 +62,7 @@ namespace benchmark {
bool KeepRunning();
};
typedef boost::function<void(State&)> BenchFunction;
typedef std::function<void(State&)> BenchFunction;
class BenchRunner
{

View File

@ -20,6 +20,7 @@
#include <boost/algorithm/string.hpp> // boost::trim
#include <boost/foreach.hpp> //BOOST_FOREACH
#include <functional> // std::function
/** WWW-Authenticate to present with 401 Unauthorized response */
static const char* WWW_AUTH_HEADER_DATA = "Basic realm=\"jsonrpc\"";
@ -30,7 +31,7 @@ static const char* WWW_AUTH_HEADER_DATA = "Basic realm=\"jsonrpc\"";
class HTTPRPCTimer : public RPCTimerBase
{
public:
HTTPRPCTimer(struct event_base* eventBase, boost::function<void(void)>& func, int64_t millis) :
HTTPRPCTimer(struct event_base* eventBase, std::function<void(void)>& func, int64_t millis) :
ev(eventBase, false, func)
{
struct timeval tv;
@ -52,7 +53,7 @@ public:
{
return "HTTP";
}
RPCTimerBase* NewTimer(boost::function<void(void)>& func, int64_t millis)
RPCTimerBase* NewTimer(std::function<void(void)>& func, int64_t millis)
{
return new HTTPRPCTimer(base, func, millis);
}

View File

@ -58,12 +58,13 @@
#include <boost/algorithm/string/replace.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/bind/bind.hpp>
#include <boost/function.hpp>
#include <boost/interprocess/sync/file_lock.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/thread.hpp>
#include <openssl/crypto.h>
#include <functional> // for std::function
#if ENABLE_ZMQ
#include "zmq/zmqnotificationinterface.h"
#endif

View File

@ -42,6 +42,7 @@
#include <QTimer>
#include <QStringList>
#include <QThread>
#include <functional>
// TODO: add a scrollback limit, as there is currently none
// TODO: make it possible to filter out categories (esp debug messages when implemented)
@ -97,7 +98,7 @@ class QtRPCTimerBase: public QObject, public RPCTimerBase
{
Q_OBJECT
public:
QtRPCTimerBase(boost::function<void(void)>& _func, int64_t millis):
QtRPCTimerBase(std::function<void(void)>& _func, int64_t millis):
func(_func)
{
timer.setSingleShot(true);
@ -109,7 +110,7 @@ private Q_SLOTS:
void timeout() { func(); }
private:
QTimer timer;
boost::function<void(void)> func;
std::function<void(void)> func;
};
class QtRPCTimerInterface: public RPCTimerInterface
@ -117,7 +118,7 @@ class QtRPCTimerInterface: public RPCTimerInterface
public:
~QtRPCTimerInterface() {}
const char *Name() { return "Qt"; }
RPCTimerBase* NewTimer(boost::function<void(void)>& func, int64_t millis)
RPCTimerBase* NewTimer(std::function<void(void)>& func, int64_t millis)
{
return new QtRPCTimerBase(func, millis);
}

View File

@ -23,6 +23,7 @@
#include <boost/thread.hpp>
#include <boost/algorithm/string/case_conv.hpp> // for to_upper()
#include <functional> // for std::function
#include <memory> // for unique_ptr
#include <unordered_map>
@ -46,22 +47,22 @@ static struct CRPCSignals
boost::signals2::signal<void (const CRPCCommand&)> PostCommand;
} g_rpcSignals;
void RPCServer::OnStarted(boost::function<void ()> slot)
void RPCServer::OnStarted(std::function<void ()> slot)
{
g_rpcSignals.Started.connect(slot);
}
void RPCServer::OnStopped(boost::function<void ()> slot)
void RPCServer::OnStopped(std::function<void ()> slot)
{
g_rpcSignals.Stopped.connect(slot);
}
void RPCServer::OnPreCommand(boost::function<void (const CRPCCommand&)> slot)
void RPCServer::OnPreCommand(std::function<void (const CRPCCommand&)> slot)
{
g_rpcSignals.PreCommand.connect(boost::bind(slot, boost::placeholders::_1));
}
void RPCServer::OnPostCommand(boost::function<void (const CRPCCommand&)> slot)
void RPCServer::OnPostCommand(std::function<void (const CRPCCommand&)> slot)
{
g_rpcSignals.PostCommand.connect(boost::bind(slot, boost::placeholders::_1));
}
@ -566,7 +567,7 @@ void RPCUnsetTimerInterface(RPCTimerInterface *iface)
timerInterface = NULL;
}
void RPCRunLater(const std::string& name, boost::function<void(void)> func, int64_t nSeconds)
void RPCRunLater(const std::string& name, std::function<void(void)> func, int64_t nSeconds)
{
if (!timerInterface)
throw JSONRPCError(RPC_INTERNAL_ERROR, "No timer handler registered for RPC");

View File

@ -17,7 +17,7 @@
#include <stdint.h>
#include <string>
#include <boost/function.hpp>
#include <functional>
#include <univalue.h>
@ -28,10 +28,10 @@ class CRPCCommand;
namespace RPCServer
{
void OnStarted(boost::function<void ()> slot);
void OnStopped(boost::function<void ()> slot);
void OnPreCommand(boost::function<void (const CRPCCommand&)> slot);
void OnPostCommand(boost::function<void (const CRPCCommand&)> slot);
void OnStarted(std::function<void()> slot);
void OnStopped(std::function<void()> slot);
void OnPreCommand(std::function<void(const CRPCCommand&)> slot);
void OnPostCommand(std::function<void(const CRPCCommand&)> slot);
}
class CBlockIndex;
@ -119,7 +119,7 @@ public:
* This is needed to cope with the case in which there is no HTTP server, but
* only GUI RPC console, and to break the dependency of pcserver on httprpc.
*/
virtual RPCTimerBase* NewTimer(boost::function<void(void)>& func, int64_t millis) = 0;
virtual RPCTimerBase* NewTimer(std::function<void(void)>& func, int64_t millis) = 0;
};
/** Set the factory function for timers */
@ -133,7 +133,7 @@ void RPCUnsetTimerInterface(RPCTimerInterface *iface);
* Run func nSeconds from now.
* Overrides previous timer <name> (if any).
*/
void RPCRunLater(const std::string& name, boost::function<void(void)> func, int64_t nSeconds);
void RPCRunLater(const std::string& name, std::function<void(void)> func, int64_t nSeconds);
typedef UniValue(*rpcfn_type)(const JSONRPCRequest& jsonRequest);

View File

@ -10,7 +10,7 @@
// boost::thread / boost::function / boost::chrono should be ported to
// std::thread / std::function / std::chrono when we support C++11.
//
#include <boost/function.hpp>
#include <functional>
#include <boost/chrono/chrono.hpp>
#include <boost/thread.hpp>
#include <map>
@ -39,7 +39,7 @@ public:
CScheduler();
~CScheduler();
typedef boost::function<void(void)> Function;
typedef std::function<void(void)> Function;
// Call func at/after time t
void schedule(Function f, boost::chrono::system_clock::time_point t);

View File

@ -15,7 +15,7 @@
#include <set>
#include <stdlib.h>
#include <boost/function.hpp>
#include <functional>
#include <boost/bind/bind.hpp>
#include <boost/signals2/signal.hpp>
#include <boost/foreach.hpp>
@ -74,8 +74,8 @@ public:
class TorControlConnection
{
public:
typedef boost::function<void(TorControlConnection&)> ConnectionCB;
typedef boost::function<void(TorControlConnection &,const TorControlReply &)> ReplyHandlerCB;
typedef std::function<void(TorControlConnection&)> ConnectionCB;
typedef std::function<void(TorControlConnection &,const TorControlReply &)> ReplyHandlerCB;
/** Create a new TorControlConnection.
*/
@ -106,9 +106,9 @@ public:
boost::signals2::signal<void(TorControlConnection &,const TorControlReply &)> async_handler;
private:
/** Callback when ready for use */
boost::function<void(TorControlConnection&)> connected;
std::function<void(TorControlConnection&)> connected;
/** Callback when connection lost */
boost::function<void(TorControlConnection&)> disconnected;
std::function<void(TorControlConnection&)> disconnected;
/** Libevent event base */
struct event_base *base;
/** Connection to control socket */

View File

@ -173,7 +173,7 @@ bool CBlockTreeDB::ReadFlag(const std::string &name, bool &fValue) {
return true;
}
bool CBlockTreeDB::LoadBlockIndexGuts(boost::function<CBlockIndex*(const uint256&)> insertBlockIndex)
bool CBlockTreeDB::LoadBlockIndexGuts(std::function<CBlockIndex*(const uint256&)> insertBlockIndex)
{
std::unique_ptr<CDBIterator> pcursor(NewIterator());

View File

@ -14,8 +14,7 @@
#include <string>
#include <utility>
#include <vector>
#include <boost/function.hpp>
#include <functional>
class CBlockIndex;
class CCoinsViewDBCursor;
@ -122,7 +121,7 @@ public:
bool WriteTxIndex(const std::vector<std::pair<uint256, CDiskTxPos> > &list);
bool WriteFlag(const std::string &name, bool fValue);
bool ReadFlag(const std::string &name, bool &fValue);
bool LoadBlockIndexGuts(boost::function<CBlockIndex*(const uint256&)> insertBlockIndex);
bool LoadBlockIndexGuts(std::function<CBlockIndex*(const uint256&)> insertBlockIndex);
};
#endif // BITCOIN_TXDB_H