Is it possible to create a static factory method on a templated struct?

ketmar via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Jun 18 09:13:07 PDT 2016


On Saturday, 18 June 2016 at 16:05:53 UTC, Gary Willoughby wrote:
> I've tried the following code and I get the error:

you still have to instantiate you `Foo` here:

   auto foo = Foo.of!(string);

no, you can't call even static methods of *uninstantiated* 
template. uninstantiated template doesn't exist at all. this 
works, for example:

   auto foo = Foo!int.of!(string);


More information about the Digitalmars-d-learn mailing list