Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当以下工作时我很惊讶
template<typename T> void f(T &...);
我认为我必须将“T”声明为“typename ...T”,并且它只适用于 C++0x。但以上是在严格的 C++03 模式下编译的。这是怎么回事?
这只是糟糕的旧 C 可变参数语法;语法允许省略逗号。以下是等价的:
int printf(const char* fmt, ...); int printf(const char* fmt...);
你调用函数了吗?模板函数在您调用它们之前不会被编译。在 Visual Studio 2010 中,IntelliSense 显示该函数的真实语法是
template <class T> void f(T&, ...)
闻起来像旧的变量参数语法。