When compiling as C ++ 98 or C ++ 11, gcc-4.9.2 and clang-3.8 are accepted,
#include <cstdio>
template <typename T> void f(T) { printf("T\n"); }
template <> void f<int>(int) { printf("int\n"); }
template <> void f<>(double) { printf("double\n"); }
template <> void f(float) { printf("float\n"); }
int main() {
f(1L);
f(10);
f(10.0);
f(10.0F);
}
I see that the C ++ 11 standard §14.7.2 (7) allows the output of template trailing arguments in explicit specialized specializations, but I cannot determine if the terser form marked is allowed HERE.
Are these compilers appropriate or is it some kind of extension?
source
share