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

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

 



Bart,
  Well, since I'm just quoting the spec, I might as well add that insection 14.1 paragraph 7, the limitations on template parameters arelisted:
A non-type template-parameter shall not be declared to have floatingpoint, class, or void type. [Example:template<double d> class X; // errortemplate<double* pd> class Y; // OKtemplate<double& rd> class Z; // OK—end example]
corey
On 5/31/05, corey taylor <corey.taylor@xxxxxxxxx> wrote:> Bart,> >   According to section 14.3.2 paragraph 1 of the C++ specification:> > A template-argument for a non-type, non-template template-parameter> shall 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 function> template-ids but excluding non-static class members, expressed as &> id-expression where the & is> optional if the name refers to a function or array, or if the> corresponding 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