January 23, 2015 Error: closures are not yet supported in CTFE | ||||
---|---|---|---|---|
| ||||
I tried: -- import std.stdio, std.algorithm; auto unique(){ bool[int] c; return (int a){ if (a in c) return false; else{ c[a] = true; return true; } }; } void main() { [1, 5, 5, 2, 1, 5, 6, 6].filter!(unique()).writeln; } -- And got: Error: closures are not yet supported in CTFE This works: void main() { auto x = unique(); [1, 5, 5, 2, 1, 5, 6, 6].filter!x.writeln; } Is first version near? |
Copyright © 1999-2021 by the D Language Foundation