digitalmars.D.learn - How to Distinguish between a Lambda and a Function Template at Compile
- Meta (22/22) Mar 26 2014 Is this a safe way to distinguish between function literals and
Is this a safe way to distinguish between function literals and function literal templates at compile time? import std.functional; import std.traits; template makeFunAlias(alias F) if (isSomeFunction!(typeof(F)) || is(typeof(F) == void)) { static if (is(typeof(F) == void)) { alias makeFunAlias = unaryFun!(F!char); } else { alias makeFunAlias = unaryFun!F; } } void main() { alias test1 = makeFunAlias!((char c) => c); alias test2 = makeFunAlias!(function(char c) => c); alias test3 = makeFunAlias!(c => c); }
Mar 26 2014