Skip to content

Commit c336525

Browse files
committed
Merge #10395: Replace boost::function with std::function (C++11)
1b936f5 Replace boost::function with std::function (C++11) (practicalswift) Tree-SHA512: c4faec8cf3f801842010976115681f68ffa08fbc97ba50b22e95c936840f47e1b3bd8d7fd2f5b4e094b5a46bf3d29fc90b69d975a99e77322c0d19f8a00d53d3
2 parents e317c0d + 1b936f5 commit c336525

File tree

11 files changed

+26
-30
lines changed

11 files changed

+26
-30
lines changed

src/bench/bench.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "bench.h"
66
#include "perf.h"
77

8+
#include <assert.h>
89
#include <iostream>
910
#include <iomanip>
1011
#include <sys/time.h>

src/bench/bench.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
#ifndef BITCOIN_BENCH_BENCH_H
66
#define BITCOIN_BENCH_BENCH_H
77

8+
#include <functional>
9+
#include <limits>
810
#include <map>
911
#include <string>
1012

11-
#include <boost/function.hpp>
1213
#include <boost/preprocessor/cat.hpp>
1314
#include <boost/preprocessor/stringize.hpp>
1415

@@ -59,7 +60,7 @@ namespace benchmark {
5960
bool KeepRunning();
6061
};
6162

62-
typedef boost::function<void(State&)> BenchFunction;
63+
typedef std::function<void(State&)> BenchFunction;
6364

6465
class BenchRunner
6566
{

src/httprpc.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ static const char* WWW_AUTH_HEADER_DATA = "Basic realm=\"jsonrpc\"";
3030
class HTTPRPCTimer : public RPCTimerBase
3131
{
3232
public:
33-
HTTPRPCTimer(struct event_base* eventBase, boost::function<void(void)>& func, int64_t millis) :
33+
HTTPRPCTimer(struct event_base* eventBase, std::function<void(void)>& func, int64_t millis) :
3434
ev(eventBase, false, func)
3535
{
3636
struct timeval tv;
@@ -52,7 +52,7 @@ class HTTPRPCTimerInterface : public RPCTimerInterface
5252
{
5353
return "HTTP";
5454
}
55-
RPCTimerBase* NewTimer(boost::function<void(void)>& func, int64_t millis)
55+
RPCTimerBase* NewTimer(std::function<void(void)>& func, int64_t millis)
5656
{
5757
return new HTTPRPCTimer(base, func, millis);
5858
}

src/init.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
#include <boost/algorithm/string/replace.hpp>
6060
#include <boost/algorithm/string/split.hpp>
6161
#include <boost/bind.hpp>
62-
#include <boost/function.hpp>
6362
#include <boost/interprocess/sync/file_lock.hpp>
6463
#include <boost/thread.hpp>
6564
#include <openssl/crypto.h>

src/qt/rpcconsole.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class QtRPCTimerBase: public QObject, public RPCTimerBase
9898
{
9999
Q_OBJECT
100100
public:
101-
QtRPCTimerBase(boost::function<void(void)>& _func, int64_t millis):
101+
QtRPCTimerBase(std::function<void(void)>& _func, int64_t millis):
102102
func(_func)
103103
{
104104
timer.setSingleShot(true);
@@ -110,15 +110,15 @@ private Q_SLOTS:
110110
void timeout() { func(); }
111111
private:
112112
QTimer timer;
113-
boost::function<void(void)> func;
113+
std::function<void(void)> func;
114114
};
115115

116116
class QtRPCTimerInterface: public RPCTimerInterface
117117
{
118118
public:
119119
~QtRPCTimerInterface() {}
120120
const char *Name() { return "Qt"; }
121-
RPCTimerBase* NewTimer(boost::function<void(void)>& func, int64_t millis)
121+
RPCTimerBase* NewTimer(std::function<void(void)>& func, int64_t millis)
122122
{
123123
return new QtRPCTimerBase(func, millis);
124124
}

src/rpc/server.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,17 @@ static struct CRPCSignals
4444
boost::signals2::signal<void (const CRPCCommand&)> PreCommand;
4545
} g_rpcSignals;
4646

47-
void RPCServer::OnStarted(boost::function<void ()> slot)
47+
void RPCServer::OnStarted(std::function<void ()> slot)
4848
{
4949
g_rpcSignals.Started.connect(slot);
5050
}
5151

52-
void RPCServer::OnStopped(boost::function<void ()> slot)
52+
void RPCServer::OnStopped(std::function<void ()> slot)
5353
{
5454
g_rpcSignals.Stopped.connect(slot);
5555
}
5656

57-
void RPCServer::OnPreCommand(boost::function<void (const CRPCCommand&)> slot)
57+
void RPCServer::OnPreCommand(std::function<void (const CRPCCommand&)> slot)
5858
{
5959
g_rpcSignals.PreCommand.connect(boost::bind(slot, _1));
6060
}
@@ -536,7 +536,7 @@ void RPCUnsetTimerInterface(RPCTimerInterface *iface)
536536
timerInterface = NULL;
537537
}
538538

539-
void RPCRunLater(const std::string& name, boost::function<void(void)> func, int64_t nSeconds)
539+
void RPCRunLater(const std::string& name, std::function<void(void)> func, int64_t nSeconds)
540540
{
541541
if (!timerInterface)
542542
throw JSONRPCError(RPC_INTERNAL_ERROR, "No timer handler registered for RPC");

src/rpc/server.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
#include <stdint.h>
1616
#include <string>
1717

18-
#include <boost/function.hpp>
19-
2018
#include <univalue.h>
2119

2220
static const unsigned int DEFAULT_RPC_SERIALIZE_VERSION = 1;
@@ -25,9 +23,9 @@ class CRPCCommand;
2523

2624
namespace RPCServer
2725
{
28-
void OnStarted(boost::function<void ()> slot);
29-
void OnStopped(boost::function<void ()> slot);
30-
void OnPreCommand(boost::function<void (const CRPCCommand&)> slot);
26+
void OnStarted(std::function<void ()> slot);
27+
void OnStopped(std::function<void ()> slot);
28+
void OnPreCommand(std::function<void (const CRPCCommand&)> slot);
3129
}
3230

3331
class CBlockIndex;
@@ -115,7 +113,7 @@ class RPCTimerInterface
115113
* This is needed to cope with the case in which there is no HTTP server, but
116114
* only GUI RPC console, and to break the dependency of pcserver on httprpc.
117115
*/
118-
virtual RPCTimerBase* NewTimer(boost::function<void(void)>& func, int64_t millis) = 0;
116+
virtual RPCTimerBase* NewTimer(std::function<void(void)>& func, int64_t millis) = 0;
119117
};
120118

121119
/** Set the factory function for timers */
@@ -129,7 +127,7 @@ void RPCUnsetTimerInterface(RPCTimerInterface *iface);
129127
* Run func nSeconds from now.
130128
* Overrides previous timer <name> (if any).
131129
*/
132-
void RPCRunLater(const std::string& name, boost::function<void(void)> func, int64_t nSeconds);
130+
void RPCRunLater(const std::string& name, std::function<void(void)> func, int64_t nSeconds);
133131

134132
typedef UniValue(*rpcfn_type)(const JSONRPCRequest& jsonRequest);
135133

src/scheduler.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
//
99
// NOTE:
10-
// boost::thread / boost::function / boost::chrono should be ported to
11-
// std::thread / std::function / std::chrono when we support C++11.
10+
// boost::thread / boost::chrono should be ported to std::thread / std::chrono
11+
// when we support C++11.
1212
//
1313
#include <boost/chrono/chrono.hpp>
1414
#include <boost/thread.hpp>

src/torcontrol.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include <set>
1515
#include <stdlib.h>
1616

17-
#include <boost/function.hpp>
1817
#include <boost/bind.hpp>
1918
#include <boost/signals2/signal.hpp>
2019
#include <boost/foreach.hpp>
@@ -73,8 +72,8 @@ class TorControlReply
7372
class TorControlConnection
7473
{
7574
public:
76-
typedef boost::function<void(TorControlConnection&)> ConnectionCB;
77-
typedef boost::function<void(TorControlConnection &,const TorControlReply &)> ReplyHandlerCB;
75+
typedef std::function<void(TorControlConnection&)> ConnectionCB;
76+
typedef std::function<void(TorControlConnection &,const TorControlReply &)> ReplyHandlerCB;
7877

7978
/** Create a new TorControlConnection.
8079
*/
@@ -105,9 +104,9 @@ class TorControlConnection
105104
boost::signals2::signal<void(TorControlConnection &,const TorControlReply &)> async_handler;
106105
private:
107106
/** Callback when ready for use */
108-
boost::function<void(TorControlConnection&)> connected;
107+
std::function<void(TorControlConnection&)> connected;
109108
/** Callback when connection lost */
110-
boost::function<void(TorControlConnection&)> disconnected;
109+
std::function<void(TorControlConnection&)> disconnected;
111110
/** Libevent event base */
112111
struct event_base *base;
113112
/** Connection to control socket */

src/txdb.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ bool CBlockTreeDB::ReadFlag(const std::string &name, bool &fValue) {
169169
return true;
170170
}
171171

172-
bool CBlockTreeDB::LoadBlockIndexGuts(boost::function<CBlockIndex*(const uint256&)> insertBlockIndex)
172+
bool CBlockTreeDB::LoadBlockIndexGuts(std::function<CBlockIndex*(const uint256&)> insertBlockIndex)
173173
{
174174
std::unique_ptr<CDBIterator> pcursor(NewIterator());
175175

0 commit comments

Comments
 (0)