Hi, try and run the following code. An explanation:
I have two template classes for the test: D and I which are defined by 3 double/integer parameters.
I've put a printf call in their ctor to see the parameter values.
In main(), I try to create several objects of D and I. And as you will run this code, you'll see that each behaves really weird. For example:

D<1,0,0>, D<-1,0,0> and D<2,0,0> give the same output: 1,1,1 , but D<3,0,0> gives the correct output: 3,0,0. If you change d1 to, say, D<5,0,0>, then d1,d2 and d3 will all give output: 5,0,0! It's as if d1..d3 are initialized with the same template instance, but d4 isn't!!! why!?!?!?

D<20,0,0> and D<-20,0,0> give the same output: 20,0,0.
The 'I' objects seem to be OK with any value.
Anyway, look for yourselves. WHAT IS GOING ON HERE?

And the weirdest one of all: try running it in the debugger, put a breakpoint on the 'printf' and as soon as you get there, take a look at the 'Context' combo box in VStudio. See what happens when you reach d4 and continue....

Note: I even tried to work with 'float' instead of 'double', since it's only 32 bits (I thought it may have sth to do with it). No change.


template <double x, double y, double z>
class D
{
public: D() { printf("%f %f %f\n", x,y,z); }
};

template <int x, int y, int z>
class I
{
public: I() { printf("%d %d %d\n", x,y,z); }
};

int main(int argc, char* argv[])
{
D<1.0,0,0> d1;
D<-1.0,0,0> d2;
D<2.0,0,0> d3;
D<20.0,0,0> d4;
D<(-20.0),0,0> d5;
D<0,10,0> d6;
D<0,-3.0,0> d7;
D<0,-10.0,0> d8;

I<1,0,0> i1;
I<-1,0,0> i2;
I<0,-10,0> i3;
I<0,10,0> i4;

return 0;
}