This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Strange error message about a template class not being a class
- To: Lutz Kettner <kettner at cs dot unc dot edu>
- Subject: Re: Strange error message about a template class not being a class
- From: llewelly at edevnull dot com
- Date: 21 Sep 2000 12:55:45 -0600
- Cc: gcc-bugs at gcc dot gnu dot org
- References: <Pine.LNX.4.10.10009210229280.1266-100000@momo.cs.unc.edu>
Lutz Kettner <kettner@cs.unc.edu> writes:
> Bug report:
>
> Compiler: g++ version 2.95.2 19991024 (release)
> System: redhat Linux 6.1 on a Pentium III
> Compiler call and messages:
>
> ++ design2.C
> design2.C:17: `p_HDS<p_Items>' is not a class, struct, or union type
> design2.C:17: syntax error before `{'
>
> The program:
> // design.2
> // ------------------------------------------
>
> template <class T>
> struct HalfedgeDS {
> typedef T* Handle;
> };
>
> template < class p_Items, template < class I> class p_HDS>
> struct Polyhedron_3 {
> typedef p_HDS< p_Items> HDS;
> typedef typename HDS::Handle Handle;
> void foo( Handle v );
> };
>
> template < class p_Items, template < class I> class p_HDS >
> void Polyhedron_3<p_Items,p_HDS>::foo( Handle v) {}
>
>
> int main() {
> Polyhedron_3< int, HalfedgeDS> P;
> int* v = 0;
> P.foo( v);
> return 0;
> }
> // EOF //
cvs gcc compiles this code with no errors, so I think the bug is fixed.
>
> I have no workaround for this. Note, the Handle parameter and the
> external definition are necessary to create that error message.
Perhaps something like this might help:
template <class T>
struct HalfedgeDS {
};
template<typename Handle_type>
struct handle_traits
{
typedef Handle_type* Handle;
};
template < class p_Items, template < class I> class p_HDS,class
Handle_Traits=handle_traits<p_Items> >
struct Polyhedron_3 {
typedef p_HDS< p_Items> HDS;
typedef typename Handle_Traits::Handle Handle;
void foo( Handle v);
};
template < class p_Items, template < class I> class p_HDS,class
Handle_Traits >
void Polyhedron_3<p_Items,p_HDS,Handle_Traits>::
foo(typename Polyhedron_3<p_Items,p_HDS,Handle_Traits>::Handle v) {}
int main() {
Polyhedron_3< int, HalfedgeDS> P;
int* v = 0;
P.foo( v);
return 0;
}
// EOF //
gcc 2.95.2 compiles this ok.
Thank you for your bug report.