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 06:58:33 PDT 2010


Thanks!

Robert Jacques wrote:
> On Fri, 23 Apr 2010 10:25:35 -0300, Gareth Charnock 
> <gareth at oerc.ox.ac.uk> 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?
>> }
> 
> Well, first, let's make this valid D code:
> 
> 
> struct A(uint N)  {}
> 
> void unary_op(uint N)(A!N value) {}
> 
> void main(string[] args) {
>     A!(3) a3;
>     pragma(msg,typeof(a3));
>     unary_op!3(a3);
>     unary_op(a3);
> }
> 
> But that still doesn't compile.
> 
> It looks like you're running across a variant of bug 2257 
> (http://d.puremagic.com/issues/show_bug.cgi?id=2257). Please vote it up.
> 
> 



More information about the Digitalmars-d mailing list