Archive for February 7th, 2009
Member Function Pointer Template Inheritance
Saturday, February 7th, 2009My brain hurts now. But this works:
template <class T_>
class Base
{
public:
typedef void (T_::* TestFunc)();
void run_it(T_* o,TestFunc f)
{
(o->*f)();
}
};
class Child : public Base<Child>
{
public:
void test_function()
{
std::clog << "Hello Test Function Member Pointer Template Thingie From Hell!" << std::endl;
}
void Go()
{
run_it(this,&Child::test_function);
}
};
int main()
{
Child c;
c.Go();
}
It’s the keystone of an important part of what I want my C++ unit testing library to do.
I tried having Base::run_it use the implicit ‘this’ pointer instead of needing the T_ parameter, but it pukes all over the place. I may try hitting it with a bigger hammer, play some casting games and see if I can do it without rending the fabric of the space time continuum asunder.
I has teh dubm nows.
UPDATE: Why it switched fonts in the middle there I’ve no idea.
UPDATE: Once my brain recharged I realized that since I have the T_ type in the base class I CAN use the “this” pointer by explicitly casting it. Passing “this” into the base class constructor is pretty stupid.
The Twitterverse: a “Slow Tuesday Night”
Saturday, February 7th, 2009Neil Gaiman turned me on to this delightful story via twitter:
@neilgaiman
It just occurred to me that Twitter -speed is best explained by R A Lafferty’s short story “Slow Tuesday Night” which is http://bit.ly/KI2
When the hell?
Saturday, February 7th, 2009For reasons sublime and stupid, the gas in my apartment is off. Different story.
Yesterday I decided I wasn’t going to take it any more, so I went to Bruno’s on Court Street and bought a plug-in stove element thingie so I could make SOMEthing that didn’t involve a microwave or ‘hoping the water in the tap ran hot enough’.
I went from Brunos to Key Food and looked around at the wondrous new world of things I could make myself to eat and finally I lighted on the perfect thing. The roof opened up and I was bathed in the light of the divine. I probably laughed triumphantly standing there in the isle.
So I’ve just finished my breakfast. Scrambled eggs cooked in the pan grease from the full package of D’artagnan wild boar bacon. I had my Billie Holiday pandora.com station playing as I finished it off (no no, it’s not a full pound.)
I looked around and thought about it a second and was struck by a strange realization.
When the hell did I develop a sense of taste?

