here’s a template class with default template parameter:
#include <cstdio>
constexpr int d = 1;
template <int a = d> struct test;
template <> struct test<1> {
test<1>(int a) { printf("%dn", a); }
};
template <> struct test<2> {
test() { printf("%dn", 2); }
};
int main() { test t{1}; }
oddly enough, if d=1
it won’t compile, while d=2
it’s fine. if I want use it when d=1
, I have to do it like this: test<> t{1};
. isn’t it kind of counter-intuitive?