Re: 'float' is invalid template constant parameter error.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Bart,
  According to section 14.3.2 paragraph 1 of the C++ specification:
A template-argument for a non-type, non-template template-parametershall be one of:— an integral constant-expression of integral or enumeration type; or— the name of a non-type template-parameter; or— the address of an object or function with external linkage,including function templates and functiontemplate-ids but excluding non-static class members, expressed as &id-expression where the & isoptional if the name refers to a function or array, or if thecorresponding template-parameter is a reference;or— a pointer to member expressed as described in 5.3.1 .

You should note the first listed item (integral or enumeration type).
corey
On 5/31/05, Jenkins, Bart (NE) <Bart.Jenkins@xxxxxxxxxx> wrote:> 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> > >

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux