全部书籍

专业

应用 关于 Coach 登录 开始阅读

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

Computer Science · 术语表

什么是 Template argument deduction?

Definition 4.2 University Computer Science — Year 2 · 第 4 章 — Templates and Generic Programming

At a call of a function template with no explicit arguments, the compiler finds the template arguments by template argument deduction: it matches each parameter type against the type of the corresponding argument. Each template parameter must be deduced to a single type from all the arguments in which it appears; a parameter that appears in no function parameter (only in the return type, say) cannot be deduced, and must be given explicitly, as in larger<double>(3, 7.5).

在原文中阅读 →