Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is "inline" required for "void f(auto) {}" in a header?

Consider

template<typename T>
inline void f(T) {} // "inline" can be safely removed.

and

inline void f(auto) {} // Can "inline" also be safely removed?

As per the C++ standard, can inline be safely removed in the latter case?

like image 864
xmllmx Avatar asked Oct 23 '25 02:10

xmllmx


1 Answers

From [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.

Emphasis added. That doesn't leave a lot of wiggle room for inline not being the default.

like image 107
Nicol Bolas Avatar answered Oct 24 '25 18:10

Nicol Bolas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!