Anyone know what's going on here? (variable with an instantiated template as a type shows up as void when instantiating another template)
Gareth Charnock
gareth at oerc.ox.ac.uk
Fri Apr 23 07:06:07 PDT 2010
...er... ...
I think I'll just put on the dunce hat and stand in the corner then.
This is why, as someone with dyslexia, I like statically typed
languages. I hate finding out about these errors at runtime.
Lars T. Kyllingstad wrote:
> Gareth Charnock wrote:
>> Is this a bug, or am I being dense? I've tried it this on 2.036,2.042
>> and 2.043 and on each the compiler produces errors. Searched bugzilla
>> for "template and instantiated" and "template and instantiate"
>>
>> struct A(uint N) {
>> }
>> void unary_op(uint N)(A!(N)) {
>> }
>> void main() {
>> A!(3) a3;
>>
>> pragma(msg,typeof(a3)); //prints A!(3), so a3 is not void, dammit
>>
>> unary_op!3(A);// Error: cannot implicitly convert expression
>> // (A(uint N)) of type void to A!(N)
>> unary_op(A); // Error: template template.unary_op(uint N) does not
>> // match any function template declaration
>> // Error: template template.unary_op(uint N) cannot
>> // deduce template function from argument types
>> // !()(void) <== what?
>> }
>
>
> You are trying to call unary_op on the template A. Try this instead:
>
> unary_op!3(a3);
> unary_op(a3);
>
> -Lars
More information about the Digitalmars-d
mailing list