Re: Template specialization error

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

 



Mark,
This may help.  Section 14.1 paragraph 7
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/30/05, Mark Norman <mpnorman@xxxxxxxxx> wrote:> Hi,> > I'm trying to port some code to work on gcc.  Unfortunately I have> come across an error which I have been unable to solve.  I have> created a small example program which illustrates the compiler error I> get.> > Compiling the following code using gcc 3.3.4 or 3.4.3 gives the following error:> test.C: In instantiation of `Bar<void>':> test.C:31:   instantiated from here> test.C:7: error: forming reference to void> > When calling "fun<void>( k )" it appears that g++ gets confused with> the last argument in template  3 (see code) even though it should be> using the void specialization in Template 2.> > > > template<class T>> struct Foo;> > template<class T>> struct Bar> {>   typedef Foo< const T& > fooTypedef;> };> > // Template 1> template <class T>> T fun( int Key )> { };> > // Template 2> // Specialization of fun template for void.> template <> inline> void fun<void>( int Key ) { };> > // Template 3> // The following function causes the error.  If you remove/rename this function> // or replace "typename Bar<T>::fooTypedef" with "Foo< const T& >"> // it compiles ok.> template <class T>> T fun( int Key, const typename Bar<T>::fooTypedef& theFoo )> { };> > > int main()> {>   int k;> >   fun<char>( k );>   fun<void>( k );> }> > > Am I doing something incorrectly here?> > Thanks for any help you can provide.> > Mark>

[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