* explicit instantiation of methods bug.
@ 1998-04-03 21:52 Andrew Fitzgibbon
1998-04-04 14:20 ` Mark Schaefer
0 siblings, 1 reply; 2+ messages in thread
From: Andrew Fitzgibbon @ 1998-04-03 21:52 UTC (permalink / raw)
To: egcs
Hi,
I occasionally explicitly instantiate single methods of a template class,
e.g. Given
template<class Type>
struct A {
....
bool f (A<Type>& u, A<Type>& w, A<Type>& v) const { }
};
template bool A<double>::f (A< double >&, A< double >&, A< double >&) const;
I want to instantiate f and not anything else in A.
egcs gives
/users33/awf/etest.cc:7: no matching template for `A<double>::f(A<double> &, A<double> &, A<double> &) const' found
But CD2 (the latest std I have access to), section 14.7.2.8 contains the phrase
and the template may be a [member template or]
member function [which would not normally be accessible]
which would seem to imply that it ought ot be allowed, as in earlier gcc's.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: explicit instantiation of methods bug.
1998-04-03 21:52 explicit instantiation of methods bug Andrew Fitzgibbon
@ 1998-04-04 14:20 ` Mark Schaefer
0 siblings, 0 replies; 2+ messages in thread
From: Mark Schaefer @ 1998-04-04 14:20 UTC (permalink / raw)
To: Andrew Fitzgibbon; +Cc: egcs
Andrew,
I'm not sure about the state of egcs, but what you are doing could
easily be considered a partial specialization. The SGI compiler, for instance,
would try to interpret your function as "Here's how I want to define A::f for
type double"
Also, from the snippet of the standard you gave, what you are doing is
neither a member template definition, nor a member function definition. You
should know that you can't declare a member function outside of the class
declaration so what does it fall into?
I'm not sure where I stand on template instantiation. According to
Stroustrup, the compiler should be smart enough to instantiate the proper
template code without operator intervention. I consider it cheesy to insist
(like gcc 7.2 did, at least) that the user explicitly tell the compiler when he
planned to instantiate a template.
I think a lot of compilers (SGI included) have a very hard time with
template dependencies, especially when the instantiation comes from a library
function call.
--
Mark Schaefer
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1998-04-04 14:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-04-03 21:52 explicit instantiation of methods bug Andrew Fitzgibbon
1998-04-04 14:20 ` Mark Schaefer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).