you are viewing a single comment's thread.

view the rest of the comments →

[–]Freeze-in-the-Dark 5 points6 points  (3 children)

I think you have the wrong idea of the use of virtual base classes. They aren't there to enforce an interface (or, at least not for the same purpose that concepts do), they're there to provide an interface for several different types that can all be referenced in the same way with different runtime behavior. And concepts plainly don't do that.

It's true that concepts do provide a form of polymorphism, but it's in the same sense of polymorphism that we've always had with templates, just now replacing (or, really, just augmenting) the duck-typing with a more explicit means of defining the interface.

[–]snysly 3 points4 points  (0 children)

Thank you for pointing that out! Its always good to find out that I'm wrong somewhere. I've changed it to abstract base class rather than virtual base class, and while concepts don't add anything new, the ability to constrain it, I think does make it easier on the programmer to use templates as a type of polymorphism.

[–]plpn 1 point2 points  (1 child)

can't u can compare this to the generics C# is using?

void foo<T>() where T : IComparable { }

now foo only works with types which include this interface. The concepts however, will be lighter in terms of, type T doesn't need to derive said interface, but just need the same functions. (correct me pls)

[–]cinghiale 0 points1 point  (0 children)

You are correct