template functions in template classes declared outside the class definition 
Author Message
 template functions in template classes declared outside the class definition

Hi All,

I would like to know why it is not possible to declare the body of template
funtions in template classes outside the class declaration itself? (btw. this
works fine with the gnu c++ compiler)

First a class definition that even VC++ compiles without any problem:

template<typename T> class AClass
{
public:
 T* member;
 template<class S> bool TempFunc(const S& arg) const
 {
   return bool(member==arg);
 }

Quote:
};

On the other hand the following code does not compile:

template<typename T> class BClass
{
public:
  T* member;
  template<class S> bool TempFunc(const S& arg) const;

Quote:
};

template<class T> template<class S> bool BClass<T>::TempFunc(const S& arg) const
{
   return bool(member==arg);

Quote:
}

It seems that VC++ does not recognize the keyword template again directly after
template.

When is this expected to be fixed?

Best regards,
Andreas Koepf



Mon, 28 Jul 2003 01:14:01 GMT  
 template functions in template classes declared outside the class definition
Andreas,
<<
I would like to know why it is not possible to declare the body of template
funtions in template classes outside the class declaration itself?

Because it's one of those areas where VC++ is not yet up to speed with the
standard. IOW, it's not implemented yet.

--
Tomas Restrepo [VC++ MVP]

http://www.mvps.org/windev/



Mon, 28 Jul 2003 02:09:06 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Syntax for declaring a template class as a friend of a non-template class

2. Using a class as a template argument inside the definition of the class

3. Compiler error C2244 (unable to match definition to declaration) - template class function

4. friend template class within template class

5. Class Template problem: The linker can't find my class template

6. template class with a template member function

7. Template function within Template Class

8. pb with template function in non template class

9. Template member functions of template classes

10. calling template member function in template class

11. Function template as member in a class template

12. template member function - non template class - VC5 - error

 

 
Powered by phpBB® Forum Software