P
Peter A. Buhr
I cannot get the following code fragment to compile:
template<typename T1> struct X {
typedef void (X<T1>::* pmem)( int i ); // type for pointer to member routine
template<typename T2> void mem( int i ) { // create template member routine
pmem p = &X<T1>::mem<T2>; // create and initialize member pointer
}
};
int main() {
X<int> x;
x.mem<int>( 3 );
}
with gcc version 4.2.4 (Ubuntu 4.2.4-1ubuntu3). I get these errors:
g++ test2.cc
test2.cc: In member function 'void X<T1>::mem(int)':
test2.cc:4: error: expected primary-expression before '>' token
test2.cc:4: error: expected primary-expression before ';' token
So am I:
1. attempting to do something that is invalid in the language?
2. incorrectly specifying the syntax for the address of the member routine?
3. attempting to do something valid but currently unimplemented by the
specified version of gcc?
Any help would be appreciated.
template<typename T1> struct X {
typedef void (X<T1>::* pmem)( int i ); // type for pointer to member routine
template<typename T2> void mem( int i ) { // create template member routine
pmem p = &X<T1>::mem<T2>; // create and initialize member pointer
}
};
int main() {
X<int> x;
x.mem<int>( 3 );
}
with gcc version 4.2.4 (Ubuntu 4.2.4-1ubuntu3). I get these errors:
g++ test2.cc
test2.cc: In member function 'void X<T1>::mem(int)':
test2.cc:4: error: expected primary-expression before '>' token
test2.cc:4: error: expected primary-expression before ';' token
So am I:
1. attempting to do something that is invalid in the language?
2. incorrectly specifying the syntax for the address of the member routine?
3. attempting to do something valid but currently unimplemented by the
specified version of gcc?
Any help would be appreciated.