Alfonso Morra wrote:
Carl Daniel [VC++ MVP] wrote:
Alfonso Morra wrote:
Does VC 7.1 support template specialization and partial
specialization ?
Yes.
Do I have to define my specializations insitu (in header file), or can I
define them elsewhere (in a .cpp file)?. There seems to be some
confusion in this matter, wrt VC 7.1
Declarations of all partial class template and explicit function and
class template specializations should always go in headers (for all
compilers), since the declaration of a specialization must appear before
that specialization is used, otherwise the code has undefined behaviour.
Explicit class template specializations should also be defined in the
header (otherwise they will be incomplete types).
Definitions of members of partial specializations should generally go in
headers (except when your compiler supports "export", which VC does not).
Definitions of explicit function template specializations or members of
explicitly specialized class templates should go in .cpp files (unless
declared inline, or defined in the class body).
I hope that is reasonably clear. Visual C++ implements the "Borland"
model of template instantiation, where definitions of non-explicit
template specializations must always be visible at the point of
instantiation.
Tom