c++ - C++03: keep default copy constructor when using template constructor -
Imagine I create a square with template constructor to define implementation later:
struct A {template & lt; Typename T & gt; A (CONST T & AGR); }; How can I avoid indirectly generated copy creator A (const A & amp;) of the overdeliver compiler? In C ++ 11, I can do something like this
#include & lt; Type_traits & gt; Struct A {Template & lt; Typename t, class = typename std :: enable_if & lt; Std :: is_same & lt; A, T & gt; :: value & gt; :: type & gt; A (CONST T & AGR); }; And this works but C +0 03 does not support the default template logic here is there any solution?
You do not need to do anything. The compiler-built coppy constructor will kick in as needed. A copy maker may not be a template, for example,
#include & lt; Iostream & gt; Struct A {template & lt; Typename T & gt; A (CONST T & AGR) {std :: cout & lt; & Lt; "Templates \ n"; }}; Int main () {A one (42); // template CTAR A (A); // copy ctor a c = b; // copy ctor} Output:
template