mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-04-30 14:43:11 +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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T, class... U> void callhooks(hookset<T> *h, U... args) {
|
template<class T, class... U> void callhooks(hookset<T> *h, U&&... args) {
|
||||||
if(h) for(auto& p: *h) p.second(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) {
|
if(h) for(auto& p: *h) {
|
||||||
auto z = p.second(args...);
|
auto z = p.second(std::forward<U>(args)...);
|
||||||
if(z != zero) return z;
|
if(z != zero) return z;
|
||||||
}
|
}
|
||||||
return zero;
|
return zero;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user