-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Nicolas Cornu
committed
Dec 13, 2024
1 parent
6219819
commit 6df9a3b
Showing
2 changed files
with
22 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#pragma | ||
|
||
#include <list> | ||
|
||
template <typename T> | ||
class signal_ { | ||
public: | ||
template <typename F> | ||
void connect(F f) { | ||
functors.push_back(f); | ||
} | ||
|
||
void send(T wc) { | ||
for (auto& f: functors) { | ||
std::invoke(f, wc); | ||
} | ||
} | ||
|
||
private: | ||
std::list<std::function<void(T)>> functors; | ||
}; |