Using member function templates in template class under VC++ 5.0 
Author Message
 Using member function templates in template class under VC++ 5.0

        I have a rather simple question about the C++ language  as implemented by
VC++ 5.0.  The question itself is a straightforward one, but it does
involve a new feature of the language present starting only in VC++ 5.0:
Member Function Templates.

        In particular, I'm trying to find a way to use member function templates
within template classes under VC++ 5.0    As the code below illustrates,
when I define the body of a member function template "inline" (that is,
within the template class definition itself), things seem to work fine.
But I get in hot water when I try to defer the definition of a member
function template until after the surrounding class has been defined.   In
other words, in the code below, I can't figure out *any* way to define
"SimpleFn"  outside the "Container" class (or even to define
specializations of it for particular instances, which is not what is
needed, but somewhat related to it,)

        Any help would be **enormously** appreciated -- will be glad to put in a
note of thanks into the doct{*filter*}dissertation you helped facilitate!

Nate Osgood

#include <stdio.h>
// #define  INLINE_DEFINITION 1         // uncomment the beginning of the line to
allow the inline version of the member function template to be used without

template<class T> class Container
        int w;
                Container(int t) : w(t) { }

                template<class S>  void SimpleFn(S *p)
                        printf("In call to inline `SimpleFn'\n");
                // here's the *declaration* -- the question is how to define this outside
this class
                template<class S>  void SimpleFn(S *p);  


//  ???  how to define SimpleFn out here?  ???

Container<int> c(100);
int main()
        c.SimpleFn((long *) 0);


Wed, 01 Sep 1999 03:00:00 GMT  
 [ 1 post ] 

 Relevant Pages 

1. Simple question: Member function templates in template classes under VC++ 5.0

2. template class with a template member function

3. Template member functions of template classes

4. calling template member function in template class

5. Function template as member in a class template

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

7. calling template member function in template class

8. Member function templates in VC 5.0

9. vc 5.0 fails instantiating function templates while using RTTI

10. template functions in template classes declared outside the class definition

11. Does VC++ 5.0 support member templates?

12. Does VC 5.0 support member templates?


Powered by phpBB® Forum Software