Tous les livres

Professionnel

Applis À propos Coach Connexion Commencer la lecture

Computer Science · Glossaire

Qu'est-ce que « Static polymorphism » ?

Definition 4.9 University Computer Science — Year 2 · Chapitre 4 — Templates and Generic Programming

Static polymorphism is the use of templates to write code that works with every type satisfying its requirements, where the operation to run for each type is chosen at compile time, during instantiation. It is opposed to the subtype polymorphism of Chapter 3, chosen at run time through a dispatch table.

Where the comparison happens. qsort is compiled once for every type, so it can only call the comparison through a pointer it receives; std::sort is instantiated for int and the lambda’s type, and the comparison becomes part of its own loop.
Where the comparison happens. qsort is compiled once for every type, so it can only call the comparison through a pointer it receives; std::sort is instantiated for int and the lambda’s type, and the comparison becomes part of its own loop.
Lire dans le chapitre →