This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Strange error message about a template class not being a class


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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]