#include <iostream>
template<typename T, int = 0>
struct test {
typedef char type[3];
};
template<int N>
struct test<long *, N> {
typedef char type[7];
};
int main()
{
std::cout << sizeof(test<int*>::type) << std::endl; // 3
std::cout << sizeof(test<long*>::type) << std::endl; // 7
return 0;
}
予想通りsizeof(test<long*>::type) == 3
です。なぜそれは7ですか?テンプレート型の奇妙な挙動
なぜ3になると思いますか? –