6
template<class T>
std::vector<T> convert(int argument)
{
}

int main()
{
  decltype(&convert<int>);
  return 0;
}

以下给出了 Visual Studio 2010 的此错误:

error C3555: incorrect argument to 'decltype'

为什么?

我正在尝试创建一个 std::map ,其中键是枚举,值是函数。

4

1 回答 1

9

VS2010 错误。该链接也有一个解决方法:

template <typename T> T identity(T);
decltype(identity(&convert<int>));
于 2012-09-13T10:48:39.980 回答