[phobos] Scoped

David Simcha dsimcha at gmail.com
Mon Aug 9 19:47:09 PDT 2010


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
}



More information about the phobos mailing list