November 05, 2015 Can't call nested template function unless it's anonymous? | ||||
---|---|---|---|---|
| ||||
///////////////////////// test.d ///////////////////////// // Call alias with a parameter. void callAlias(alias f)() { f(42); } alias Identity(alias X) = X; void main() { int local; // Declare an anonymous function template // which writes to a local. alias a = Identity!((i) { local = i; }); // Declare a function template which does // the same thing. void b(T)(T i) { local = i; } callAlias!a; // Works callAlias!b; // Error: function test.main.b!int.b is a // nested function and cannot be accessed // from test.callAlias!(b).callAlias } ////////////////////////////////////////////////////////// Is this a bug or some sort of limitation? As far as I can tell, a and b are essentially the same, except one is anonymous. |
Copyright © 1999-2021 by the D Language Foundation