|
-
September 12th, 2012, 03:04 AM
#2
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|