Martin said:
In "C++ Templates, The Complete Guide" i read that template copy-con is
never default copy constructor, and template assignment-op is never a copy
assignment operator. Could someone please explain how I could
declate/override the two.
I am not sure how much you did understand, so, the text is talking about
this situation
struct A {
template<class T> A(T const&); // "copy"-constructor
};
This "copy" constructor will not be used if 'T' is 'A'. The compiler will
still generate another copy constructor,
A(A const&);
according to its usual rules of generating one, and will use it when copy
construction is performed from another 'A' object.
Same with the assignment op.
To make sure you _do_ have control over the copy construction process from
another 'A' object, define both the template and the non-template c-tors:
struct A {
template<class T> A(T const&);
A(A const&);
};
and do your "true" copy-construction in the latter and "pseudo" copy
construction in the former. Remember that there is no way to invoke one
c-tor from another, so if you need to do some common processing, pull it
out into a separate function.
V