This code snippet just won't compile in a conforming compiler:
because of the floating point template parameter....Code:template<> struct series<0.0, 0, 0>
If this "specialization" is useful, how come MS would have discarded it?
Thanks
Jack
Printable View
This code snippet just won't compile in a conforming compiler:
because of the floating point template parameter....Code:template<> struct series<0.0, 0, 0>
If this "specialization" is useful, how come MS would have discarded it?
Thanks
Jack
The C++ standard specifies that there are restrictions on what a non-type template parameter can be, and double isn't one of them.
It can be:
An integer type or enum constant/literal value
the name of a non-type template-parameter
the address of a function or object with external linkage
a pointer to member
You 'sort of' can make double values with a bit of rule bending.
You could either pass an integer parameter and use it as a double with a fixed scale. Suppose you wanted a double with at most 3 decimal positions, then you would pass an integer where integer/1000 is the double value you want.
You could pass 2 integers: a Divident and a divisor where the quotient is the desired double (so the double template parameter is divident / divisor).
The drawback is that it may not help for all template needs. And not all double values can be accurately enough be described by an X/Y type expression.
Interesting. I wasn't aware of those last two.Quote:
the address of a function or object with external linkage
a pointer to member
Erased (Duplicate)
If I want to pass 0.001 i would pass 1, for example?
Then inside the function, I do 1/1000 to retrieve back the value I am after....
Okay, fair enough
Thanks a lot, have a nice day
Jack