August 09, 2010 [phobos] Scoped | ||||
---|---|---|---|---|
| ||||
std.typecons.scoped doesn't appear to work with private constructors. This would be useful for modules using their own classes, since they presumably know the implementation details and can rely on them to make sure using scoped is safe. This is because emplace apparently can't see the private constructors. class Foo { private this(uint num) {} public this(string str) {} } import std.typecons; void main() { auto a = scoped!Foo("a string"); // Works. auto b = scoped!Foo(666); // Fails } |
Copyright © 1999-2021 by the D Language Foundation