c++ - GCC Templates: expected »(« before »>« token -
this question has answer here:
i don't understand why following code doesn't compile:
template< typename typearg > class data { public: struct selector1 { }; template< typename selector > void foo() { } }; template< typename typearg > class test { public: void test(); }; template< typename typearg > void test< typearg >::test() { data< typearg > data; data.foo< typename data< typearg >::selector1 >(); }
i have tested gcc 4.6 , gcc 4.9. both give me same error:
test.cpp: in member function »void test::test()«: test.cpp:28:51: error: expected »(« before »>« token test.cpp:28:53: error: expected primary-expression before »)« token
can tell me needs done code compile?
since type of data
dependent, nature of data.foo
not known , needs disambiguated:
data.template foo<typename data< typearg >::selector1>(); // ^^^^^^^^
Comments
Post a Comment