Unusual template specialisation behavior
Matthias Walter
walter at mail.math.uni-magdeburg.de
Fri Feb 8 11:24:36 PST 2008
Christopher Wright Wrote:
> Matthias Walter wrote:
> > Hello guys,
> >
> > Here's a (minimal) code snippet for my problem:
> >
> > | struct Expression (R, E) { }
> > |
> > | struct ResolveReference (T)
> > | {
> > | alias T reference_type;
> > | }
> > |
> > | struct ResolveReference (T : Expression !(R, E))
>
> The compiler should have caught this, I think. You have R and E, but
> they aren't defined. They default to int (which is why you saw that
> behavior), but not being defined, they should be a compile-time error.
>
> The proper way to do this, unfortunately, involves static if rather than
> overloading. At least if you want your users to supply a single argument
> in all cases.
Thanks for that hint. How would such a static if look like?
I currently have
| static if (is (T == struct)).
This works for distinguishing native datatypes like int from my Expression-Templates.
But is there a native way to statically check, whether T is some specialisation like
"T == Expression !(R, E)" (for all R, E).
best regards
Matthias Walter
More information about the Digitalmars-d-learn
mailing list