S
Stepan Seycek
Hallo,
I'm writing a test system with the approach of providing the test
infrastructure in a base class and adding the test methods in the
concrete derived test classes by registering member function pointers.
However my code fails to compile with:
g++ -o mfp -WAll mfp.cpp
mfp.cpp: In member function `void Base<T>::registerTest(int (T::*)())':
mfp.cpp:11: error: expected unqualified-id before '.' token
Here's a reduced version of the source:
//-[mfp.cpp]----------------------------------------------------
#include <vector>
template <typename T>
class Base
{
public:
typedef int (T::*TestMethod)();
Base () {}
virtual ~Base() {}
void registerTest(TestMethod tm) {tests_.push_back(tm);}
private:
typedef std::vector<TestMethod> tests_;
};
class Derived : Base<Derived>
{
public:
int testIt() {}
void setup() {registerTest(&Derived::testIt);}
};
int main(int argc, char **argv)
{
Derived test;
test.setup();
}
//--------------------------------------------------------------
Any hint is appreciated!
Br,
Stepan Seycek
I'm writing a test system with the approach of providing the test
infrastructure in a base class and adding the test methods in the
concrete derived test classes by registering member function pointers.
However my code fails to compile with:
g++ -o mfp -WAll mfp.cpp
mfp.cpp: In member function `void Base<T>::registerTest(int (T::*)())':
mfp.cpp:11: error: expected unqualified-id before '.' token
Here's a reduced version of the source:
//-[mfp.cpp]----------------------------------------------------
#include <vector>
template <typename T>
class Base
{
public:
typedef int (T::*TestMethod)();
Base () {}
virtual ~Base() {}
void registerTest(TestMethod tm) {tests_.push_back(tm);}
private:
typedef std::vector<TestMethod> tests_;
};
class Derived : Base<Derived>
{
public:
int testIt() {}
void setup() {registerTest(&Derived::testIt);}
};
int main(int argc, char **argv)
{
Derived test;
test.setup();
}
//--------------------------------------------------------------
Any hint is appreciated!
Br,
Stepan Seycek