header 中的 "void f(auto) {}" 是否需要 "inline"?
Is "inline" required for "void f(auto) {}" in a header?
考虑
template<typename T>
inline void f(T) {} // "inline" can be safely removed.
和
inline void f(auto) {} // Can "inline" also be safely removed?
根据 C++ 标准,可以 inline
在后一种情况下可以安全删除吗?
来自[dcl.fct]/18:
An abbreviated function template is a function declaration that has one or more generic parameter type placeholders ([dcl.spec.auto]). An abbreviated function template is equivalent to a function template ([temp.fct]) whose template-parameter-list includes one invented type template-parameter for each generic parameter type placeholder of the function declaration, in order of appearance.
添加了重点。这不会为 inline
不是默认值留下很大的回旋余地。
考虑
template<typename T>
inline void f(T) {} // "inline" can be safely removed.
和
inline void f(auto) {} // Can "inline" also be safely removed?
根据 C++ 标准,可以 inline
在后一种情况下可以安全删除吗?
来自[dcl.fct]/18:
An abbreviated function template is a function declaration that has one or more generic parameter type placeholders ([dcl.spec.auto]). An abbreviated function template is equivalent to a function template ([temp.fct]) whose template-parameter-list includes one invented type template-parameter for each generic parameter type placeholder of the function declaration, in order of appearance.
添加了重点。这不会为 inline
不是默认值留下很大的回旋余地。