Is there a way in C ++ to determine if a pointer type is a descendant of a specific base type? For example:

template<class T> void Foo(T *obj) { if (Extends<Object>(obj)) ... else ... } 
  • Is this needed at compile time or runtime? Refine the task. - gecube
  • on idea in rantayme since it is necessary that, depending on the type, this or that piece of code is executed and the code is always compiled. if the same thing can be cranked at the compilation stage, then such a scheme will be fine. - Roma Tulin
  • one
    Wrap <a href= en.wikipedia.org/wiki/Dynamic_cast> dynamic_cast<> </a> into a pattern. - gecube
  • 2
    it works only for polymorphic types, but I need it for any .. actually found the answer .. std :: is_base_of <BaseType, ChildType> :: value - Roma Tyulin
  • one
    @RomaTyulin Could you, please, issue your last comment as an answer (so that future readers will immediately see the solution to the problem and the question will not hang on the list of unanswered questions)? Just copy the part you need from him in response and heal the answer points - this is normal practice. - StateItPrimitive

0