Function call inlining

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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...
}




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux