Template meta-programming with member function pointers?
Posted
by wheaties
on Stack Overflow
See other posts from Stack Overflow
or by wheaties
Published on 2010-05-17T18:20:36Z
Indexed on
2010/05/17
18:30 UTC
Read the original article
Hit count: 234
Is it possible to use member function pointers with template meta-programming? Such as:
class Connection{
public:
string getName() const;
string getAlias() const;
//more stuff
};
typedef string (Connection::*Con_Func)() const;
template<Con_Func _Name>
class Foo{
Connection m_Connect;
public:
void Foo(){
cout << m_Connect.(*_Name);
}
};
typedef Foo<&Connection::getName> NamedFoo;
typedef Foo<&Connection::getAlias> AliasFoo;
Granted, this is rather contrived but is it possible? (yes, there are probably much better ways but humor me.)
© Stack Overflow or respective owner