public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Function call inlining
@ 2015-08-27 15:34 Matwey V. Kornilov
  2015-08-28  7:59 ` Andrew Haley
  0 siblings, 1 reply; 3+ messages in thread
From: Matwey V. Kornilov @ 2015-08-27 15:34 UTC (permalink / raw)
  To: gcc-help

Hello,

Please consider the following code from the SO:
http://stackoverflow.com/a/32237033/1879547

template<class Ret, class T, class Func, int... Is>
auto apply(T&& p, int index, Func func, seq<Is...>) -> Ret
{
     using FT = Ret(T&&, Func);
     static constexpr FT* arr[] = { &apply_one<Ret, Is, T&&, Func>... };
     return arr[index](std::forward<T>(p), func);
}

I use gcc-4.8.2 and see that arr[index](std::forward<T>(p), func) call
is not inlined.
The question here is the following. All function pointers are known at
compile time. So, why don't expand this code into analogous to the
following?

switch(index) {
	case 0:
		// inline arr[0]
	break;
	case 1:
		// inline arr[1]
	// etc...
}

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-08-28  8:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-27 15:34 Function call inlining Matwey V. Kornilov
2015-08-28  7:59 ` Andrew Haley
2015-08-28  8:05   ` Matwey V. Kornilov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).