Fix handling of scoped callback parameters in eventcore callbacks.
This commit is contained in:
parent
32d360baac
commit
964d72f3b5
2 changed files with 66 additions and 17 deletions
|
@ -50,6 +50,7 @@ struct Waitable(alias wait, alias cancel, CB, on_result...)
|
|||
alias Callback = CB;
|
||||
|
||||
static if (on_result.length == 0) {
|
||||
static assert(!hasAnyScopeParameter!Callback, "Need to retrieve results with a callback because of scoped parameter");
|
||||
ParameterTypeTuple!Callback results;
|
||||
void setResult(ref ParameterTypeTuple!Callback r) { this.results = r; }
|
||||
} else {
|
||||
|
@ -245,3 +246,11 @@ private string generateParamNames(Fun)()
|
|||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
private template hasAnyScopeParameter(Callback) {
|
||||
import std.algorithm.searching : any;
|
||||
import std.traits : ParameterStorageClass, ParameterStorageClassTuple;
|
||||
alias SC = ParameterStorageClassTuple!Callback;
|
||||
static if (SC.length == 0) enum hasAnyScopeParameter = false;
|
||||
else enum hasAnyScopeParameter = any!(c => c & ParameterStorageClass.scope_)([SC]);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue