回答編集履歴
2
修正
test
CHANGED
@@ -55,3 +55,55 @@
|
|
55
55
|
}
|
56
56
|
|
57
57
|
```
|
58
|
+
|
59
|
+
修正
|
60
|
+
|
61
|
+
```C++
|
62
|
+
|
63
|
+
// MyVendorLibApi.hpp
|
64
|
+
|
65
|
+
class MyVendorLibApi
|
66
|
+
|
67
|
+
{
|
68
|
+
|
69
|
+
private:
|
70
|
+
|
71
|
+
class MyVendorLibListener* my_vendorlib_listener;
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
public:
|
76
|
+
|
77
|
+
template<class T>
|
78
|
+
|
79
|
+
void set_callback(void(T::*fp)(int a), T *obj)
|
80
|
+
|
81
|
+
{
|
82
|
+
|
83
|
+
set_callback( boost::bind(fp, obj, boost::placeholders::_1) );
|
84
|
+
|
85
|
+
}
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
void set_callback( std::function<void(int)> callback );
|
90
|
+
|
91
|
+
};
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
//MyVendorLibApi.cpp
|
96
|
+
|
97
|
+
#include "my_vendorlib_listener.hpp"
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
void MyVendorLibApi::set_callback( std::function<void(int)> callback ){
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
my_vendorlib_listener->set_callback( callback );
|
106
|
+
|
107
|
+
}
|
108
|
+
|
109
|
+
```
|
1
誤字修正
test
CHANGED
@@ -28,7 +28,11 @@
|
|
28
28
|
|
29
29
|
this->callback = boost::bind(fp, obj, boost::placeholders::_1);
|
30
30
|
|
31
|
+
push_callback();
|
32
|
+
|
31
33
|
}
|
34
|
+
|
35
|
+
private:
|
32
36
|
|
33
37
|
void push_callback( void );
|
34
38
|
|
@@ -50,30 +54,4 @@
|
|
50
54
|
|
51
55
|
}
|
52
56
|
|
53
|
-
|
54
|
-
|
55
|
-
// 実行
|
56
|
-
|
57
|
-
{
|
58
|
-
|
59
|
-
MyVendorLibApi api;
|
60
|
-
|
61
|
-
struct TEST {
|
62
|
-
|
63
|
-
void func( int ){}
|
64
|
-
|
65
|
-
} test;
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
api.set_callback( &TEST::func, &test );
|
70
|
-
|
71
|
-
api.push_callback();
|
72
|
-
|
73
|
-
}
|
74
|
-
|
75
|
-
|
76
|
-
|
77
57
|
```
|
78
|
-
|
79
|
-
ただ、あまりスマートじゃないような気もします。
|