如何隐式调用类对象的模板化函数调用运算符?
class User_Type
{
public:
template< typename T > T operator()() const;
};
void function()
{
User_Type user_var;
int int_var_0 = user_var.operator()< int >(); // explicit function call operator; ugly.
int int_var_1 = user_var< int >(); // implicit function call operator.
}
g++-4.9 -Wall -Wextra
的输出错误是:
error: expected primary-expression before ‘int’
auto int_var_1 = user_var< int >();
^