Incase it doesn’t show up:

  • jorp@lemmy.world
    link
    fedilink
    arrow-up
    0
    ·
    3 months ago

    I don’t think it’s what the person you’re replying to meant, but template metaprogramming in modern c++ allows the use of “duck typing” aka “static polymorphism” where you can code against an interface without requiring inheritance.

    This works by using stuff like SFINAE and type traits

    • void_star@lemmy.world
      link
      fedilink
      arrow-up
      0
      ·
      3 months ago

      Typically this is done with CRTP which does require inheritance. But I agree, you can do some meta programming or use concepts which can enforce interfaces in a different way. But back to the original comment that interfaces via inheritance are objectively bad, I don’t think there’s any consensus that this is true. And pure virtual interfaces and CRTP are both common use cases of inheritance in modern C++ codebases and are generally considered good design patterns.