From: "Matwey V. Kornilov" <matwey.kornilov@gmail.com>
To: gcc-help@gcc.gnu.org
Subject: Function call inlining
Date: Thu, 27 Aug 2015 15:34:00 -0000 [thread overview]
Message-ID: <mrnale$fhr$1@ger.gmane.org> (raw)
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...
}
next reply other threads:[~2015-08-27 15:34 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-27 15:34 Matwey V. Kornilov [this message]
2015-08-28 7:59 ` Andrew Haley
2015-08-28 8:05 ` Matwey V. Kornilov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='mrnale$fhr$1@ger.gmane.org' \
--to=matwey.kornilov@gmail.com \
--cc=gcc-help@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).