1010#define MUDUO_BASE_WEAKCALLBACK_H
1111
1212#include < functional>
13- #include < boost/function.hpp>
14- #include < boost/shared_ptr.hpp>
13+ #include < memory>
1514
1615namespace muduo
1716{
@@ -20,14 +19,12 @@ namespace muduo
2019
2120#ifdef __GXX_EXPERIMENTAL_CXX0X__
2221
23- // FIXME: support std::shared_ptr as well, maybe using template template parameters
24-
2522template <typename CLASS , typename ... ARGS >
2623class WeakCallback
2724{
2825 public:
2926
30- WeakCallback (const boost ::weak_ptr<CLASS >& object,
27+ WeakCallback (const std ::weak_ptr<CLASS >& object,
3128 const std::function<void (CLASS *, ARGS ...)>& function)
3229 : object_(object), function_(function)
3330 {
@@ -37,7 +34,7 @@ class WeakCallback
3734
3835 void operator ()(ARGS &&... args) const
3936 {
40- boost ::shared_ptr<CLASS > ptr (object_.lock ());
37+ std ::shared_ptr<CLASS > ptr (object_.lock ());
4138 if (ptr)
4239 {
4340 function_ (ptr.get (), std::forward<ARGS >(args)...);
@@ -50,19 +47,19 @@ class WeakCallback
5047
5148 private:
5249
53- boost ::weak_ptr<CLASS > object_;
50+ std ::weak_ptr<CLASS > object_;
5451 std::function<void (CLASS *, ARGS ...)> function_;
5552};
5653
5754template <typename CLASS , typename ... ARGS >
58- WeakCallback<CLASS , ARGS ...> makeWeakCallback (const boost ::shared_ptr<CLASS >& object,
55+ WeakCallback<CLASS , ARGS ...> makeWeakCallback (const std ::shared_ptr<CLASS >& object,
5956 void (CLASS ::*function)(ARGS ...))
6057{
6158 return WeakCallback<CLASS , ARGS ...>(object, function);
6259}
6360
6461template <typename CLASS , typename ... ARGS >
65- WeakCallback<CLASS , ARGS ...> makeWeakCallback (const boost ::shared_ptr<CLASS >& object,
62+ WeakCallback<CLASS , ARGS ...> makeWeakCallback (const std ::shared_ptr<CLASS >& object,
6663 void (CLASS ::*function)(ARGS ...) const )
6764{
6865 return WeakCallback<CLASS , ARGS ...>(object, function);
@@ -77,8 +74,8 @@ class WeakCallback
7774{
7875 public:
7976
80- WeakCallback (const boost ::weak_ptr<CLASS >& object,
81- const boost ::function<void (CLASS *)>& function)
77+ WeakCallback (const std ::weak_ptr<CLASS >& object,
78+ const std ::function<void (CLASS *)>& function)
8279 : object_(object), function_(function)
8380 {
8481 }
@@ -87,7 +84,7 @@ class WeakCallback
8784
8885 void operator ()() const
8986 {
90- boost ::shared_ptr<CLASS > ptr (object_.lock ());
87+ std ::shared_ptr<CLASS > ptr (object_.lock ());
9188 if (ptr)
9289 {
9390 function_ (ptr.get ());
@@ -100,19 +97,19 @@ class WeakCallback
10097
10198 private:
10299
103- boost ::weak_ptr<CLASS > object_;
104- boost ::function<void (CLASS *)> function_;
100+ std ::weak_ptr<CLASS > object_;
101+ std ::function<void (CLASS *)> function_;
105102};
106103
107104template <typename CLASS >
108- WeakCallback<CLASS > makeWeakCallback (const boost ::shared_ptr<CLASS >& object,
105+ WeakCallback<CLASS > makeWeakCallback (const std ::shared_ptr<CLASS >& object,
109106 void (CLASS ::*function)())
110107{
111108 return WeakCallback<CLASS >(object, function);
112109}
113110
114111template <typename CLASS >
115- WeakCallback<CLASS > makeWeakCallback (const boost ::shared_ptr<CLASS >& object,
112+ WeakCallback<CLASS > makeWeakCallback (const std ::shared_ptr<CLASS >& object,
116113 void (CLASS ::*function)() const )
117114{
118115 return WeakCallback<CLASS >(object, function);
0 commit comments