Topic: Static template member functions
Author: maxtal@physics.su.OZ.AU (John Max Skaller)
Date: Wed, 27 Apr 1994 23:14:46 GMT Raw View
In article <khlim.767354242@hurricane> khlim@hurricane.seas.ucla.edu (Kenneth Heng Lim) writes:
>If a user specializes a template class's static member function, must the
>user also specialize all the non-static members?
1) No. You can specialise _definitions_ of members,
including variables, independently. The ones you dont
define will be generated if used.
2) Dont know. If you specialise the class interface,
I do not know if you must define all the members, or if
you can 'inherit' definitions from the generic interface.
I guess you must define what you will use, that is,
you cant expect the compiler to generate members of a
completely unrelated class -- but I dont know.
One could argue the compiler ought to at least try.
--
JOHN (MAX) SKALLER, INTERNET:maxtal@suphys.physics.su.oz.au
Maxtal Pty Ltd, CSERVE:10236.1703
6 MacKay St ASHFIELD, Mem: SA IT/9/22,SC22/WG21
NSW 2131, AUSTRALIA
Author: khlim@hurricane.seas.ucla.edu (Kenneth Heng Lim)
Date: Tue, 26 Apr 1994 09:57:22 GMT Raw View
If a user specializes a template class's static member function, must the
user also specialize all the non-static members?
Ex:
template<class T> class Foo {
public:
static T bar();
Foo(T);
T do_fun(T):
...
};
int Foo::bar() { return 5; }
// must also provide definition for Foo(int) && do_fun(int)?
{ ... Foo<int> t; // legal? }
Lucid's lcc (3.01p2) accepts the above code without problems