/* Hello, I have a problem with this compiler gcc version 3.2 20020927 (prerelease) on Window XP. For details please see attachment in mail. Compiling this file with g++ -w test.cpp results in test.cpp: In function `int main()': test.cpp:55: no match for `int * Wrapper&' operator Compiling this with g++ -w -DNO_ERRORS test.cpp works. The define just adds an explicit cast and now the compiler can deduce how the "*" in line 63 can be compiled. So I guess the compiler can only use conversion operators from template classes that have been instanciated at least once explicitly. Could you please tell me if I (once again) failed to understand the standard and explain the reasons and ramifications [what if different compilation units instantiate different possible conversions, will this ambuguity be detected ?] for this behaviour or if this is really a bug ? Regards Burkhard Neppert b.neppert@dr-staedtler.de */ #include using namespace std; template struct Wrapper { Wrapper() : val() {} Wrapper(T const & v) : val(v) {} operator T&() { return val; } operator T const&() const { return val; } Wrapper & operator=(T const & rhs) { val=rhs; return *this; } T val; }; int main() { vector > foo; #if defined(NO_ERRORS) // If we just use this conversion from Wrapper => int once explicitly // then the rest compiles OK (int)(*foo.begin()); #endif for(vector >::iterator iter=foo.begin(); iter!=foo.end(); ++iter) { (*iter)=10*(*iter)+1; // Depends on the explicit call of conversion from Wrapper to int } return 0; }