Gcc (4.7.2) は、このコードのコンパイル中に小さなエラーをスローします:
#include <iostream>
template<typename T>
struct test
{
template<int n>
int select() const
{
return n;
}
};
template<typename T>
struct test_wrapper
{
void print() const
{
std::cout << t.select<3>() << std::endl; // L.18
}
test<T> t;
};
int main()
{}
エラーは次のとおりです。
test3.cpp: In member function 'void test_wrapper<T>::print() const':
test3.cpp:18:34: error: expected primary-expression before ')' token
test<T> t
たとえば、特殊なタイプで変更するとtest<void> t
、このエラーは消えます。
問題はどこだ?