This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
'float' is invalid template constant parameter error.
- From: "Jenkins, Bart \(NE\)" <Bart dot Jenkins at gd-ais dot com>
- To: <gcc-help at gcc dot gnu dot org>
- Date: Tue, 31 May 2005 16:14:22 -0400
- Subject: 'float' is invalid template constant parameter error.
All,
Here is a bit of code, boiled down to it's essence, that works fine in both Visual C++ 6.0 sp 6 and Intel for Windows 8.1 but fails in GCC 3.2.3 and 3.4:
AdaNumeric_T.cpp
--------------
template <typename T, T delta_val>
class AdaNumeric_T
{
private:
T t;
};
typedef AdaNumeric_T<int,1> AdaIntType;
typedef AdaNumeric_T<float,1.0> AdaFloatType;
int main(int argc, char* argv[])
{
return 0;
}
(Please ignore the fact that I don't do anything with 'delta_val' and nothing is getting assigned to 'T t')
THE PROBLEM:
The typedef 'typedef AdaNumeric_T<int,1> AdaIntType;' works fine but the version right beneath it with the float type does not. I get a:
"'float' is not a valid type for a template constant parameter"
Which seems strange.
Is the Intel compiler more ANSI compliant than GCC or is this a bug in GCC? Does this work in GCC 4.0?
TIA
Bart Jenkins
ph: (703) 263-2883
General Dynamics
Advanced Information Systems
12450 Fair Lakes Circle
Fairfax, VA 22033