I want to do something like the following:
import core.stdc.stdio;
Test!(T, "mode1") make_test(T)(T data) {
Test!(T, "mode1") t = { data };
return t;
}
struct Test(T, string mode = "ref") { T data; }
extern (C) void main() {
auto obj = make_test(20);
static if (is(typeof(obj) == Test)) { printf("YES!!!!!!!\n"); }
}
So, I just want to be able check if a variable is a given struct type. I also want to be able to do something similar but having a (templated) function that returns a struct type without having to be limited to a specific initialization of it.
Obviously, the given code will not work. It will result to the following error message:
Error: template struct `test.Test(T, string mode = "ref")` is used as a type without instantiation; to instantiate it use `Test!(arguments)`
Any ideas? Also, like in every question I make, the solution must be "betterC" compatible.
CLARIFICATION
I have a bad feeling that the post is not clear enough, so I'll save us all some time by making it clear.
I know I can do this:
static if (is(typeof(obj) == Test!(int, "mode1"))) { printf("YES!!!!!!!\n"); }
And it will work but this is not what I want. I want to much EVERY "Test" type regardless of what's the value
of its templated arguments.