vous avez tout dit, mais ce qui est plus compliqué est que programmation générique a toujours été une casse tête pour les développeurs qui dorme beaucoup, oui l'évolution du c++11\14 en fait un peu trop, mais son évolution vient bien sûr changer et faciliter ce qui était autre foi une casse tête. je suis encore étudiant et mes amis me déteste quand g fait du c++, mais je pense que java lui n'a fait l'histoire que parce qu'il est simplicité de c++ mais son niveau ne change pas, la question que je me pose est: "jusqu'où les objets?"

Citation Envoyé par A. Stepanov
My approach works, theirs does not work. Try to implement a simple thing in the object oriented way, say, max. I do not know how it can be done. Using generic programming I can write:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
template <class StrictWeakOrdered>
inline StrictWeakOrdered& max(StrictWeakOrdered& x,
StrictWeakOrdered& y) {
return x < y ? y : x;
}
and
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
template <class StrictWeakOrdered>
inline const StrictWeakOrdered& max(const StrictWeakOrdered& x,
const StrictWeakOrdered& y) {
return x < y ? y : x;
}
Question:
This mean a radical change of mind from both imperative and OO thinking. What are the benefits, and the drawbacks, of this paradigm compared to the "standard" OO programming of SmallTalk or, say, Java?

Answer:
My approach works, theirs does not work. Try to implement a simple thing in the object oriented way, say, max. I do not know how it can be done. Using generic programming I can write:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
template <class StrictWeakOrdered>
inline StrictWeakOrdered& max(StrictWeakOrdered& x,
StrictWeakOrdered& y) {
return x < y ? y : x;
}
and
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
template <class StrictWeakOrdered>
inline const StrictWeakOrdered& max(const StrictWeakOrdered& x,
const StrictWeakOrdered& y) {
return x < y ? y : x;
}
(you do need both & and const &). And then I define what strict weak ordered means. Try doing it in Java. You can't write a generic max() in Java that takes two arguments of some type and has a return value of that same type. Inheritance and interfaces don't help. And if they cannot implement max or swap or linear search, what chances do they have to implement really complex stuff? These are my litmus tests: if a language allows me to implement max and swap and linear search generically - then it has some potential.
www.stlport.org/resources/StepanovUSA.html