On Tuesday, 7 May 2013 at 06:41:25 UTC, Meta wrote:
I don't really understand why either of these error messages are occurring. The first is just incomprehensible, and the second seems like it should work. In this case, rhs is fully accessible at compile time in the expression (a + b), so why does the compiler complain?

1) typeof don't work on types. Period. It is often inconvenient in generic code (I'd love it typeof(T) to be T for simplicity) but it is how it is done now. In your case pragma(msg, T) will be correct one.

2) template parameter must be known at compile time. "rhs" is a plain function parameter, so compiler can't be sure it is known at compile time, so it is an error. Same goes for n. In general, only enum's and template parameters can be assumed to be known at compile-time. Your code seems to wrongly mix plain variables with template code all over.

If you can explain for behavior/API you are trying to achieve, most likely I'll be able to provide a more idiomatic D solution.

Reply via email to