Is there a way to define a template
assertInheritsFrom<A, B>
such that
assertsInheritsFrom<A, B>
compiles if and only if
class A : public B { ... } // struct A is okay too
Thanks!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can read this section Detecting convertibility and inheritance at compile time from Alexandrescu’s book.
EDIT: One more link for the same: http://www.ddj.com/cpp/184403750 Look for Detecting convertibility and inheritance