Why is it clear that a template function instantiation will not be inlined?
Web Technologies
Web Development
2 years ago
5
Star Rating
1
Rating
_x000D_
_x000D_
Regarding Function passed as template argument, the community wiki answer provided by Ben Supnik discusses the issue of inlining instantiated function templates.
In that answer is the following code:
template
int do_op(int a, int b, OP op)
{
return op(a,b,);
}
int add(int a, b) { return a + b; }
int (* func_ptr)(int, int) = add;
int c = do_op(4,5,func_ptr);
The answer goes on to say this (in regards to the final line, which instantiates the function template do_op):
clearly this is not getting inlined.
My question is this: Why is it clear that this is not getting inlined?
Posted on 16 Aug 2022, this text provides information on Web Development related to Web Technologies. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.
Take Quiz To Earn Credits!
Turn Your Knowledge into Earnings.