Re: floating point template parameters (called specialization?)
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.
Re: floating point template parameters (called specialization?)
the address of a function or object with external linkage
a pointer to member
Interesting. I wasn't aware of those last two.
"It doesn't matter how beautiful your theory is, it doesn't matter how smart you are. If it doesn't agree with experiment, it's wrong."
Richard P. Feynman
Re: floating point template parameters (called specialization?)
Erased (Duplicate)
"It doesn't matter how beautiful your theory is, it doesn't matter how smart you are. If it doesn't agree with experiment, it's wrong."
Richard P. Feynman
Re: floating point template parameters (called specialization?)
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
Bookmarks