Unusual template specialisation behavior
Christopher Wright
dhasenan at gmail.com
Fri Feb 8 06:07:27 PST 2008
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.
More information about the Digitalmars-d-learn
mailing list