File tree 5 files changed +35
-9
lines changed
5 files changed +35
-9
lines changed Original file line number Diff line number Diff line change 9
9
#include < map>
10
10
11
11
class EventEmitter {
12
-
13
12
std::map<std::string, void *> events;
14
13
std::map<std::string, bool > events_once;
15
14
@@ -33,15 +32,14 @@ class EventEmitter {
33
32
int _listeners = 0 ;
34
33
35
34
public:
36
-
37
35
int maxListeners = 10 ;
38
36
39
37
int listeners () {
40
38
return this ->_listeners ;
41
39
}
42
40
43
41
template <typename Callback>
44
- void on (std::string name, Callback cb) {
42
+ void on (const std::string& name, Callback cb) {
45
43
46
44
auto it = events.find (name);
47
45
if (it != events.end ()) {
@@ -62,7 +60,7 @@ class EventEmitter {
62
60
}
63
61
64
62
template <typename Callback>
65
- void once (std::string name, Callback cb) {
63
+ void once (const std::string& name, Callback cb) {
66
64
this ->on (name, cb);
67
65
events_once[name] = true ;
68
66
}
@@ -73,7 +71,7 @@ class EventEmitter {
73
71
this ->_listeners = 0 ;
74
72
}
75
73
76
- void off (std::string name) {
74
+ void off (const std::string& name) {
77
75
78
76
auto it = events.find (name);
79
77
Original file line number Diff line number Diff line change 6
6
"url" : " git://github.com/datcxx/cxx-eventemitter.git"
7
7
},
8
8
"homepage" : " https://github.com/datcxx/cxx-eventemitter" ,
9
- "dependencies" : {},
9
+ "dependencies" : {
10
+ },
10
11
"scripts" : {
11
- "test" : " c++ -std=c++2a test/index.cxx -o test/index && ./test/index"
12
+ "test" : [
13
+ " clang++ -std=c++2a" ,
14
+ " -O1 -g -fsanitize=address -fno-omit-frame-pointer" ,
15
+ " test/index.cxx -o test/index &&" ,
16
+ " ASAN_OPTIONS=detect_leaks=1" ,
17
+ " ASAN_OPTIONS=fast_unwind_on_malloc=0" ,
18
+ " ./test/index"
19
+ ]
12
20
},
13
21
"files" : [
14
22
" index.hxx"
Original file line number Diff line number Diff line change 12
12
} \
13
13
} while (0 );
14
14
15
- int main (int argc, char * argv[] ) {
15
+ int main () {
16
16
int testcount = 0 ;
17
17
int testplan = 9 ;
18
18
@@ -25,7 +25,7 @@ int main (int argc, char* argv[]) {
25
25
26
26
ASSERT (" maxListeners should be 10" , ee.maxListeners == 10 );
27
27
28
- ee.on (" event1" , [&](int a, std::string b) {
28
+ ee.on (" event1" , [&](int a, std::string& b) {
29
29
ASSERT (" first arg should be equal to 10" , a == 10 );
30
30
ASSERT (" second arg should be foo" , b == " foo" );
31
31
});
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version =" 1.0" >
4
+ <dict >
5
+ <key >CFBundleDevelopmentRegion </key >
6
+ <string >English </string >
7
+ <key >CFBundleIdentifier </key >
8
+ <string >com.apple.xcode.dsym.index </string >
9
+ <key >CFBundleInfoDictionaryVersion </key >
10
+ <string >6.0 </string >
11
+ <key >CFBundlePackageType </key >
12
+ <string >dSYM </string >
13
+ <key >CFBundleSignature </key >
14
+ <string >???? </string >
15
+ <key >CFBundleShortVersionString </key >
16
+ <string >1.0 </string >
17
+ <key >CFBundleVersion </key >
18
+ <string >1 </string >
19
+ </dict >
20
+ </plist >
You can’t perform that action at this time.
0 commit comments