全部书籍

专业

应用 关于 Coach 登录 开始阅读

书籍暂未推出简体中文版——当前显示英文版。

Computer Science · 术语表

什么是 Static polymorphism?

Definition 4.9 University Computer Science — Year 2 · 第 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.
在原文中阅读 →