c++ - Why were concepts (generic programming) conceived when we already had classes and interfaces? -
: I understand that STL concepts were present, And it would be stupid to call "classes" or "interface", when in fact they only document human (human) concepts and can not be translated into C ++ code at that time, but when language is enhanced Opportunities are provided for concepts, why they only modify the capabilities of classes and / or introduced interfaces Do not be? Is not too similar to an interface (100% abstract class information)? Seeing this, I think that there is a lack of support for volunteers only in the interface, but maybe the Axioms can be presented in C ++'s interface (considering adopting a conceptual convergence in C ++) Has not got them? I think that the concepts of self can be easily added to such a C ++ interface (auto interface, comforter, any?). Is not a concept_map very similar to the ADAP pattern? If all the methods are inline, then the adapter is not necessarily present beyond time compilation; The compiler simply gives the interface the call instead of the inlineed versions, the target object calls directly during the runtime. I've heard about something called static object-oriented programming, which essentially motivates objects - concepts in generic programming, thus allowing the power of using OOP without most performance overhead. Why was this idea not considered? I hope this is quite clear. If you think I was not, then I can rewrite it; There is a big difference between just OP and generic programming, Predestination / Em>. In OOP, when you design a class, then your interfaces were seems to be useful and it has been done. On the other hand, in generic programming, it is possible to use fits the bill and, as long as the class corresponds to a set of requirements (mainly methods, but internal constants or types) Concept proposal is formally about this, so that the method can be detected at the time of examining the method signature rather than immediately adjusting the body. This checks template methods more easily, because some methods can be rejected without any prompt if the concepts do not match. The advantage of the concepts is that you are not suffering from repatriation, you can choose a class from Library 1, choose a method from Library 2, and if it fits, you sleep If not, you can use a concept map). In OO, you have to write a complete adapter every time. You are right that the two look the same. The difference is mainly about the time of compulsive (and the fact that the concept is still a static transmission like the interface instead of dynamic transmission). Concepts are more open, so easy to use.
Comments
Post a Comment