mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-12-24 17:10:36 +00:00
perfect forwarding in callhooks and callhandlers
This commit is contained in:
parent
4384f65962
commit
0f3b00835e
8
hyper.h
8
hyper.h
@ -644,13 +644,13 @@ template<class T, class U> int addHook(hookset<T>*& m, int prio, const U& hook)
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<class T, class... U> void callhooks(hookset<T> *h, U... args) {
|
||||
if(h) for(auto& p: *h) p.second(args...);
|
||||
template<class T, class... U> void callhooks(hookset<T> *h, U&&... args) {
|
||||
if(h) for(auto& p: *h) p.second(std::forward<U>(args)...);
|
||||
}
|
||||
|
||||
template<class T, class V, class... U> V callhandlers(V zero, hookset<T> *h, U&... args) {
|
||||
template<class T, class V, class... U> V callhandlers(V zero, hookset<T> *h, U&&... args) {
|
||||
if(h) for(auto& p: *h) {
|
||||
auto z = p.second(args...);
|
||||
auto z = p.second(std::forward<U>(args)...);
|
||||
if(z != zero) return z;
|
||||
}
|
||||
return zero;
|
||||
|
Loading…
Reference in New Issue
Block a user