www.digitalmars.com         C & C++   DMDScript  

c++ - method template specialization in class templates and virtual method templates

reply "Michele" <noways aliceposta.it> writes:
template<typename tt,typename tt2>
class template_test
{
 public:
  tt member;

  template <typename mtt>
  mtt tmethod(mtt p)
  {
   tt tmp;
   return p;
  }

/* omitting the specialization no test.cpp(19) : Error: 'tmethod' is not a
class template error
  template <>
  tt2 tmethod<char>(char p)
  {
   tt2 tmp
   return tmp;
  }
  template <>
  long tmethod<int>(int p)
  {
   return 2;
  }
*/
  operator tt()
  {
   return member;
  }

  template <typename vmtt>
  virtual vmtt vtmethod(vmtt p)  //line 26
  {
   return p;
  }
};

template_test<template_test<int,double>,char> otempl;

dmc -Ae test.cpp
test.cpp(19) : Error: 'tmethod' is not a class template
Internal error: template 1714
--- errorlevel 1

dmc -Ae  test.cpp
 test.cpp(26) : Error:  storage class is illegal in this context
--- errorlevel 1


the c++ standard permit this things??? dmc will support???
thx in advice
Sep 07 2003
parent "Walter" <walter digitalmars.com> writes:
Virtual template methods are disallowed by the C++ spec. Sorry, -Walter

"Michele" <noways aliceposta.it> wrote in message
news:bjfg52$1md$1 digitaldaemon.com...
 template<typename tt,typename tt2>
 class template_test
 {
  public:
   tt member;

   template <typename mtt>
   mtt tmethod(mtt p)
   {
    tt tmp;
    return p;
   }

 /* omitting the specialization no test.cpp(19) : Error: 'tmethod' is not a
 class template error
   template <>
   tt2 tmethod<char>(char p)
   {
    tt2 tmp
    return tmp;
   }
   template <>
   long tmethod<int>(int p)
   {
    return 2;
   }
 */
   operator tt()
   {
    return member;
   }

   template <typename vmtt>
   virtual vmtt vtmethod(vmtt p)  //line 26
   {
    return p;
   }
 };

 template_test<template_test<int,double>,char> otempl;

 dmc -Ae test.cpp
 test.cpp(19) : Error: 'tmethod' is not a class template
 Internal error: template 1714
 --- errorlevel 1

 dmc -Ae  test.cpp
  test.cpp(26) : Error:  storage class is illegal in this context
 --- errorlevel 1


 the c++ standard permit this things??? dmc will support???
 thx in advice
Sep 07 2003