
Hi, ----- Original Message ----- From: "Lorenzo Caminiti" <lorcaminiti@gmail.com> To: <boost@lists.boost.org> Sent: Sunday, March 21, 2010 2:11 PM Subject: [boost] [mpl] has_function
Hello all,
Is there a way I can check if a class has a given member function using metaprogramming?
What I need is to check at compile-time if a function is overriding a virtual function or not. In the example below, z::f is overriding x::f but not y::f (which does not exist) and the compiler knows that -- is there a way I can extract that information from the compiler?
struct has_function<class Base, ... /* other parameters */ > { ... /* some implementation */ };
struct x { virtual void f() {} };
struct y { virtual void g() {} };
struct z: x, y { void f() { cout << has_function<x, &z::f>::value << endl; // print 1 cout << has_function<y, &z::f>::value << endl; // print 0 } };
(This does not compile -- I do not know how to program it so it compiles -- but it should give the idea of what I am looking for.)
maybe you can take a look at https://svn.boost.org/trac/boost/wiki/LibrariesUnderConstruction#Boost.Conce... This library was abandoned because Concepts will be part of the language. It contains alot of traits about if a class ddefines a function. I don't know if there is some some traits for virtual functions. Let us know, Vicente