如何直接调用转换运算符?

Nei*_*irk 7 c++

struct Bob
{
    template<class T>
    void operator () () const
    {
        T t;
    }

    template<class T>
    operator T () const
    {
        T t;
        return t;
    }
};
Run Code Online (Sandbox Code Playgroud)

我可以像这样直接调用Bob的operator()

Bob b;
b.operator()<int>();
Run Code Online (Sandbox Code Playgroud)

如何使用这样的特定模板参数直接调用转换运算符?

Bob b;
std::string s = b.???<std::string>();
Run Code Online (Sandbox Code Playgroud)

无法使用static_cast

Bob b;
std::string s = static_cast<std::string>(b);
Run Code Online (Sandbox Code Playgroud)

http://ideone.com/FoBKp7

error: call of overloaded ‘basic_string(Bob&)’ is ambiguous

问题 如何直接使用模板参数调用或者它是不可能的.我知道有一些使用包装函数的变通方法.

gx_*_*gx_ 12

您可以直接(显式)直接调用它:

Bob b;
std::string s = b.operator std::string();
Run Code Online (Sandbox Code Playgroud)

但它不是"使用特定的模板参数"(但不需要).

另见WhozCraig的评论