为什么有必要用std :: string :: operator +()显式调用Myclass :: operator string()?

Mar*_*tin 5 c++

请考虑以下代码.我不明白为什么我的GCC编译器不会尝试隐式使用Myclass :: operator string(),尽管定义了Myclass :: operator string():

#include <string>

using namespace std;

struct T {
};

T operator+(const T& a, const T&b) { }

struct Myclass {
    operator string() const { }
    operator T() const { }
};

int main() {
    T a;
    string b;
    Myclass c;
    c + a;  // OK
    c.operator  string() + b; // OK
    c + b; // Not OK
    /* The above line does not compile, although in <string> I see:
    basic_string<_CharT, _Traits, _Alloc>
    operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
          const basic_string<_CharT, _Traits, _Alloc>& __rhs)
     */
}
Run Code Online (Sandbox Code Playgroud)

Pup*_*ppy 2

由于字符串运算符是模板,因此无法选取它,而其他运算符则可以。