With some C++ code that does explicit template instantiation:
struct Data { } ;
template<int T1>
struct Collection {
template <int T2, int T3>
static void copyRelevantData( const Data& param, Data& res ) { }
};
template<int T1>
struct Manipulation {
template<int T2, int T3, int T4>
static void doStuff( ) {
Data from, to ;
Collection<T1>::copyRelevantData< T2, T3 >( from, to ) ;
}
};
template
void Manipulation<2>::doStuff<0, 0, 0>() ;
I'm seeing the following sort of error (intel 13 icpc output) :
vv.C(26): error: no operator ">" matches these operands
operand types are: int > Data
Collection<T1>::copyRelevantData< T2, T3 >( from, to ) ;
^
or (g++ 4.1.2) :
vv.C: In static member function 'static void Manipulation<T1>::doStuff()':
vv.C:15: error: no match for 'operator>' in 'T3 > (from, to)'
vv.C: In static member function 'static void Manipulation<T1>::doStuff() [with int T2 = 0, int T3 = 0, int T4 = 0, int T1 = 2]':
vv.C:20: instantiated from here
vv.C:15: error: invalid operands of types '<unresolved overloaded function type>' and 'int' to binary 'operator<'
This code compiles with the IBM xlC compiler (v12). I'm not sure why the template parameter list is being interpretted as a greater than, but there is clearly a portability issue here.
I'm interesting in knowing how to adjust the code to work with all compilers.
Also, should this code work (i.e. and possibly a bug with both the intel and GCC compilers), or is it invalid language use (and possibly also indicates that the xlC compiler has a bug since that compiler allows this code?)