C++ 非类型参数包奇怪地扩展

C++ 非类型参数包奇怪地扩展,c++,visual-c++,C++,Visual C++,考虑以下代码: #include <iostream> #include <typeinfo> template <size_t... s> struct str { typedef void(&ftype)(decltype(s)...); }; int main() { std::cout << typeid(str<3, 4, 5>::ftype).name() << std::endl;

考虑以下代码:

#include <iostream>
#include <typeinfo>

template <size_t... s>
struct str
{
    typedef void(&ftype)(decltype(s)...);
};

int main()
{
    std::cout << typeid(str<3, 4, 5>::ftype).name() << std::endl;
}
结果是void(uu cdecl*)(unsigned int,unsigned int,unsigned int),正如预期的那样


这是VC++中的错误吗?

有两种方法可以查看您的问题。C++语言层和QoI级别

在语言层面上,没有bug
typeid(…).name()
返回一些实现定义的字符串。没有任何限制。它甚至可以为所有类型返回相同的字符串

就MSVC本身而言,由于它可以在解决方法中确认实际的参数数量,这显然是一个问题。因此,是的,我们可以看到改进的机会,这可能需要一份报告

#include <iostream>
#include <typeinfo>

template <size_t... s>
struct str
{
    template <class Func=void(&)(decltype(s)...)>
    using ftype = Func;
};

int main()
{
    std::cout << typeid(str<3, 4, 5>::ftype<>).name() << std::endl;
}