I tried to make a traits to find if a method is virtual
: (https://ideone.com/9pfaCZ)
// Several structs which should fail depending if T::f is v
There is probably no way to determine if a specific method is virtual
. I say this because the Boost project researched traits for years and never produced such a traits test.
However, in C++11, or using the Boost library, you can use the is_polymorphic<>
template to test a type to see if the type has virtual functions. See std::is_polymorphic<> or boost::is_polymorphic<> for reference.