Can anyone cite the C++ language standard rules on instantiation of templated type conversion operators?

If I have a function bar returning type T1, and another function foo taking in type T2 and T1 is convertible to T2 via a user defined conversion operator then the statement foo(bar()) should be legal without casting T1 to T2 (invocation of the conversion operator is performed automatically by the compiler).

Now how do the rules change if the used defined conversion operator in question is a template? Now the compiler must recognize that the conversion can be acomplished if it instantiates a conversion operator template. Under MSVC7 the template diagnosis and instantiation occur automatically without help from the programmer... but on several other compliers (GNU, GHS) the complier fails because the types are unrelated. To get the user defined conversion operator to be instantiated and invoked I must help/hint the compiler by static casting the types.

Which is (lang-std) correct? automatic instantiation and invocation of template conversion operator or only instantiate template to satisify explicit cast operation.


for example:

struct opaque {
template <typename T> operator T *(void) { return 0; }
};

opaque bar(void) { return opaque(); }

void foo(int *, double *) { return; }

int main(void) {
// g++, ghs, msvc7
foo(static_cast<int *>(bar()), static_cast<double *>(bar()));

// msvc7 only
foo(bar(), bar());

return 0;
}