template<typename T>
struct Wrap {
Wrap(T *p) {}
};
#ifdef TEMPLATE
template<typename T>
void foo (Wrap<T> t) {}
#else
void foo (Wrap<int> p) {}
#endif
int main () {
foo(new int);
}
When the part is #elsecompiled, the compilation is fine and version-2 is selected. If I try to compile the part #ifdef, I expect version-1 to be selected. However, the compiler gives an error like,
error: there is no corresponding function to call `foo (int *) '
Am I touching the non deduction part template foo? If so, can anyone clarify what is the exact rule of the area not deduced ?
source
share