Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- auto bindNames(alias fn)() if(isCallable!fn) {
- class Wrapper {
- Parameters!fn parameterStorage;
- this(){
- parameterStorage = ParameterDefaults!fn;
- }
- static foreach(i, name; ParameterIdentifierTuple!fn){
- mixin("auto " ~ name ~ "(Parameters!fn[i] value){ parameterStorage[i] = value; return this; }");
- static if(is(Parameters!fn[i] == bool)){
- mixin("auto " ~ name ~ "(){ parameterStorage[i] = !parameterStorage[i]; return this; }");
- }
- }
- auto opCall(){
- return fn(parameterStorage);
- }
- }
- return new Wrapper;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement