template auto instantiation when parameters empty
Erik Smith via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed May 4 15:10:16 PDT 2016
I want to have a struct template auto instantiate when the
template parameters are defaulted or missing. Example:
struct Resource(T=int) {
static auto create() {return Resource(null);}
this(string s) {}
}
auto resource = Resource.create;
As a plain struct it works, but not as a template:
struct Resource { // works
struct Resource() { // fails
struct Resource(T=int) { // fails
At the call site, this works, but I'm hoping for a few less
symbols:
auto resource = Resource!().create;
Any ideas?
More information about the Digitalmars-d-learn
mailing list