template 使用 A = int;void f(A<0=0);//试图声明一个函数 f 接受 int,//使用默认参数 0//按预期工作://void f(A<0> = 0); 这既不能在 GCC 4.9.2 或 Clang 3.5 上编译 - 更不用说 ICC 或 VC++.显然 >= 位被解析为大于或等于运算符.但是,这对于 [temp.names]/3 来说似乎是不正确的:
名称查找(3.4)后发现名称是模板名称或operator-function-id 或 literal-operator-id 指的是一个集合重载函数的任何成员是函数模板,如果这后面跟着一个<,<总是作为template-argument-list 并且从不作为小于运算符.解析模板参数列表时,第一个非嵌套>138 作为结束分隔符 而不是一个大于运算符.[..] [ 示例:
template类 X {/* ...*
为什么两个函数的地址相同?Why do two functions have the same address?(为什么两个函数的地址相同?)
为什么 std::function 的初始化程序必须是可复制构Why the initializer of std::function has to be CopyConstructible?(为什么 std::function 的初始化程序必须是可复制构造的?)
混合模板与多态性mixing templates with polymorphism(混合模板与多态性)
我什么时候应该使用关键字“typename"?使用模When should I use the keyword quot;typenamequot; when using templates(我什么时候应该使用关键字“typename?使用模板时)
依赖名称解析命名空间 std/标准库Dependent name resolution amp; namespace std / Standard Library(依赖名称解析命名空间 std/标准库)
gcc 可以编译可变参数模板,而 clang 不能gcc can compile a variadic template while clang cannot(gcc 可以编译可变参数模板,而 clang 不能)