Topic: Template question


Author: sj@aracnet.com (Scott Johnson)
Date: 1996/09/06
Raw View
Is it legal, for a member template function, for a specialization to have
a different access specifier than the general declaration?

i.e.

class foo {
    public:
 template <class T> void bar( T& baz ) {/* blah blah */ }
    private:
 void bar <int> (int& baz) { /* blah blah blah */ }
};

Reading the April 95 DWP; this is not mentioned.  I don't have a compiler
around which supports member templates, so I can't try it out myself.


Thanks,

Scott

--
/--------------------------------------------------------------------------\
|Scott Johnson -- Professional (sometimes) SW Engineer and all-purpose Geek|
|I don't speak for nobody but myself, which everyone else is thankful for  |
\--------------------------------------------------------------------------/
---
[ comp.std.c++ is moderated.  To submit articles: Try just posting with your
                newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  Comments? mailto:std-c++-request@ncar.ucar.edu
]





Author: b91926@fibi01.fnal.gov (David Sachs)
Date: 1995/04/07
Raw View
A. What is the proper way to specify an external non-template
 function with a name and argument types that matches a
 possible template expansion?

B. What is the proper way to specify that type conversion is
 to be allowed for a template function with particular
 argument types?

The trouble is that the syntax for these very different specifications
appears to be identical. e.g.

template<class T> inline T max<T>(T a, T b)
{ return  a>b ? a : b; }


extern double max(double, double); // What does this declare ?





Author: jason@cygnus.com (Jason Merrill)
Date: 1995/04/08
Raw View
>>>>> David Sachs <b91926@fibi01.fnal.gov> writes:

> A. What is the proper way to specify an external non-template
>  function with a name and argument types that matches a
>  possible template expansion?

extern max<double> (double, double);

> B. What is the proper way to specify that type conversion is
>  to be allowed for a template function with particular
>  argument types?

extern max (double, double);

Jason