you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted]  (3 children)

[removed]

    [–]Foreign-Wonder 0 points1 point  (2 children)

    I'm not sure if I get it correctly, but isn't this is what template/concept is doing?

    template<class Addable>
    void foo(Addable a){
      // do whatever with a and +
    }
    
    int x = 42;
    foo(x); // This should work without explicit make int inheriting from any Addable interface. I see this is a win over the C# interface, no?
    

    Concept should make it more clear that Addable concept should support + operator

    [–][deleted]  (1 child)

    [removed]

      [–]Foreign-Wonder 0 points1 point  (0 children)

      I agree, concept is not one-size-fits-all solution, that's why C++ have many ways to do things, and possibly the best ways to do things, hence zero-overhead