On 2012-11-08 17:27:40 +0000, Tommi said:
..and it got me thinking, couldn't we just get rid of dynamic polymorphism and classes altogether?

Compiler can do a lot of optimizations with knowledge about classes. Also it automates a lot things that would become boilerplate with proposed manual setup of delegates for each object.

     struct Shape // Represents an interface
     {
         std::function<void (int x, int y)>        resize;
         std::function<void (int x, int y)>        moveTo;
         std::function<bool (int r, int g, int b)> draw;
     };

Dinamic polimorphism isn't gone anywhere, it was just shifted to delegates.

This approach complicates thing to much and produces template bloat with no real benefit.

Reply via email to