为什么这段代码失败了
错误 C2893:无法专门化函数模板 ''unknown-type' makeAndProcessObject(const Builder &)'
我正在使用 MSVC2012
class BBuilder
{
public:
int makeObject()
{
return 22;
}
};
template <typename Builder>
auto
makeAndProcessObject (const Builder& builder) -> decltype( builder.makeObject() )
{
auto val = builder.makeObject();
// do stuff with val
return val;
}
int main()
{
BBuilder myobj;
auto retval = makeAndProcessObject(myobj);
return 0;
}
(现场示例)