|
I am learning C++ templates and I already have a certain understanding of templates. I don't want to read C++ templates, boost, and loki. The main reason is that I think this template is not very useful. But I was ashamed, so when I searched it today, I found someone to discuss here. Indeed pointed me the direction.
Based on the comments made by everyone above, I come to this conclusion:
The application of OO is to describe such a thing. People can eat, I am a human, so I can eat, and because of the virtual existence, everyone can eat differently. OO must be of the same kind, and OO achieves compression of the same kind of behavior.
What GP said is that you can eat, and I can also eat, even if we don’t matter. People can eat, dogs can eat, and even machines have to eat. I can let them all eat here. GP does not matter which type you have, GP implements compression of different kinds of behaviors.
These two things, one vertical and one horizontal, are not contradictory. OO is omnipotent. GP that OO can do can’t be done, and OO that GP can do can also do awkward OO (different types of brothers let you be the same, Java.NET, there was no GP before, so they should all belong to this category) , But this consumes performance, clarity and maintainability. So some things still need GP to do, especially in the case of high cross-type compression requirements, or even infinite types. In this case, it is too troublesome to use GP. Let us inherit a bunch of interfaces for each class. Trouble, it's better to use it directly without inheritance (where GP is useful). We must let the compiler write the program for us (I think GP is essentially the compiler writes the program for us-instantiation).
In fact, macros can also GP, and template is a smarter GP that saves coders and is safer.
Specific to the actual development, there is no doubt that the general library we work on is the universal library we work on for infinite types, so GP uses a lot here; and we seldom use this for each enterprise application development project. GP. There are not so many different types of peers! In our development, there is no "dog and person eating" situation, but most of them are "this person eating with that person" situation. And the code logic is the most variable part. Too far away from GP. |
|