function pointer bug?
bitwise via Digitalmars-d
digitalmars-d at puremagic.com
Mon Oct 27 16:52:38 PDT 2014
>> quotes self
Here is a better example, showing that virtual function pointers
are available at compile time in C++. Essentially, I would expect
my D code to function similarly, but it won't compile.
class TestAddr {
public: virtual void test() { cout << "test" << endl; }
};
template<void (TestAddr::*FN)()>
class PtrWrapper
{
public:
void invoke(TestAddr *instance) { (instance->*FN)(); }
};
int main(int argc, const char * argv[])
{
TestAddr test;
PtrWrapper<&TestAddr::test> wrapper;
wrapper.invoke(&test);
return 0;
}
More information about the Digitalmars-d
mailing list