I've tried to narrow this down to the minimum code that exhibits the problem.

When I use a mixin, to supply the parameters for a template, it works with ONE argument, but NOT TWO.

template sizer2D() // no params here for simplicity
        {
        const char [] sizer2D = "64,64";      
        }       
template sizer1D()
        {
        const char [] sizer1D = "64"; 
        }       
        
class why_t ()
        {
        array_t!(64,64) case1;  // works
        array_t!(mixin(sizer2D!())) case2; // FAILS (error below)

        array2_t!(64) case3; // works
        array2_t!(mixin(sizer1D!())) case4; // works

        array3_t!(64) case5; // works
array3_t!(mixin(sizer2D!())) case6; // WORKS using ONE ARGUMENT method using default parameter for height (see class)
        }
        
class array_t (int width, int height)
        {
        int [width][height] data;
        }
class array2_t (int width)
        {
        int [width][width] data;
        }
class array3_t (int width, int height=width) //note default param
        {
        int [width][height] data;
        }



The error I get is:

Error: template instance array_t!64 does not match template declaration array_t(int width, int height)

Error: template instance a5test.why_t!() error instantiating

And the strange thing is, it's like it's only outputting ONE of the two numbers. If it were outputting any other gibberish, it shouldn't compile at all. And I'm not misplacing the 1D vs 2D function names because originally there was NO 1D version at all. It was just the 2D and it wouldn't compile.

Is there any way to get a PRINTOUT of the mixin code upon failure to see what it's actually trying to compile?

---------


I'm using LDC2:

LDC - the LLVM D compiler (e9b2b4):
  based on DMD v2.068.2 and LLVM 3.5.0


Reply via email to