220 18157 <5700648f-5413-4547-b1e3-43aea2ee798f@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: Adrien Hamelin <adrien.hamelin@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Proposal: Optimizing out useless functions
Date: Sat, 23 May 2015 01:46:21 -0700 (PDT)
Lines: 434
Approved: news@gmane.org
Message-ID: <5700648f-5413-4547-b1e3-43aea2ee798f@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_1862_964800397.1432370781921"
X-Trace: ger.gmane.org 1432370789 8715 80.91.229.3 (23 May 2015 08:46:29 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Sat, 23 May 2015 08:46:29 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCDJNPOCWIPBBX74QCVQKGQEG7AK25A@isocpp.org Sat May 23 10:46:25 2015
Return-path: <std-proposals+bncBCDJNPOCWIPBBX74QCVQKGQEG7AK25A@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-qk0-f200.google.com ([209.85.220.200])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCDJNPOCWIPBBX74QCVQKGQEG7AK25A@isocpp.org>)
	id 1Yw54a-0000cv-Ft
	for gclcip-std-proposals@m.gmane.org; Sat, 23 May 2015 10:46:24 +0200
Original-Received: by qkhi77 with SMTP id i77sf42101402qkh.3
        for <gclcip-std-proposals@m.gmane.org>; Sat, 23 May 2015 01:46:23 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=date:from:to:message-id:subject:mime-version:content-type
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=dxeKH1s+ZHcnM9e3i1uNxSfxRl8YBeuF+KwxoOFXoyc=;
        b=xShzfE5WiW26uynxS5aw09NzqW9ScKyuaZc+sUuzCv3FiKeeDNZZHf24u+eB6EJUYp
         tkVLeijqupuqtfUKLcz5SmU2sBwzvc1CWe2fTWf8+121B1/PZ5nBpxvSR/nT3PdrLZOU
         3SjnPie7Qx5O3VxuqlTWCkBJOjjDoy6Dk/IqYwRT0UADUmyTNmhh6mTj7awFSeRQLk75
         34DFWNJeF+yycV26yTvVaaCPVYdhayZBo/WK5cgN9MRZ26OdmoCqVK5UaR6qFNvaU9wN
         fcnTKEpxM7uCl+oUz6bmnddG2TX5o7hl5sGesRrmGwKQQg8PCCe2qjhoatGXUXiLgH7x
         zolw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:date:from:to:message-id:subject:mime-version
         :content-type:x-original-sender:reply-to:precedence:mailing-list
         :list-id:list-post:list-help:list-archive:list-subscribe
         :list-unsubscribe;
        bh=dxeKH1s+ZHcnM9e3i1uNxSfxRl8YBeuF+KwxoOFXoyc=;
        b=im90ApLRScZ2bpW4p84c0iVFJhZZpuvse8quwY0dlM46vD4uF0m0s7xudFO7by+hAu
         ax696J/OZYJyR2zNiLvoM7/McgEV35GuiaAImKMlylj6p6wtjKOFuvKWXrcT1qBmbTqR
         8ec3j1tro+L2JrH7IZHCz/LrPYsQb2EcoVHg/xc02b0YLY66bKIaYqiYln9VOUXrm1Vr
         Kn7I7ibvpujAG0m33EkzId3gijJlsiuMwMJhgp7KQPgw/0UZnjMD27OEo5r8+x6/K5KC
         tezho7XQe/p0VQEuKeiBTCRdVvqTx0c4Ah00N+6EJcyCPhj0CEt33NScKc5CytMyKSaN
         Y4OA==
X-Gm-Message-State: ALoCoQmT/9x8oXUnVayGXnSHVtlgpFUQeqAbbf7iNoNuDKRIcAcwQr/awRcyG67KtIVaHq1ucvQE
X-Received: by 10.236.70.5 with SMTP id o5mr16683236yhd.9.1432370783557;
        Sat, 23 May 2015 01:46:23 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.140.89.148 with SMTP id v20ls2384297qgd.70.gmail; Sat, 23 May
 2015 01:46:22 -0700 (PDT)
X-Received: by 10.140.20.40 with SMTP id 37mr178894qgi.26.1432370782880;
        Sat, 23 May 2015 01:46:22 -0700 (PDT)
X-Original-Sender: adrien.hamelin@gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Google-Group-Id: 399137483710
List-Post: <http://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <http://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <http://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:18157
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/18157>

------=_Part_1862_964800397.1432370781921
Content-Type: multipart/alternative; 
	boundary="----=_Part_1863_781353863.1432370781921"

------=_Part_1863_781353863.1432370781921
Content-Type: text/plain; charset=UTF-8

Hi,

I have written an idea I got to extend the C++ language on my blog and have 
been advised to post it here, so here it is. The basic idea is to help the 
compiler remove functions that are actually used but with no side effects. 
It does it automatically for simple functions, but it cannot always do it.
An example I have is with a signal system. Imagine it is like this:

template <size_t ID>
class Sender {
public:
  // some code
  static void send(/* parameters */);
};
 
template <size_t ID>
class Receiver {
public:
  // some code
  template <typename Function>
  void receive(Function f);
};

// Usage //////////////////////
 
// Elsewhere in the code ------
Receiver<0> receiver;
 
// later...
Sender<0>::send(/* parameters */);
 
// later...
receiver.receive([] (/* parameters */) {
  // something
});

Pretty simple, each signal is differentiated by an ID. When a signal needs 
to be sent, one has just to call the send() function and every receivers 
that exist at that time will receive the signal and handle it when the 
receive() function is called.
With a GUI library, for example, a lot of signals will be sent whether 
there is a receiver or not. But the send() function is not optimized out 
(at least in my test application with GCC and clang and -O3), so some CPU 
cycle are wasted when there are no receivers. My idea is then a keyword 
that indicates that if a function or a class does not exist at link time, 
when the executable is build, the dependent function calls can simply be 
removed from the program, with no side-effects, and some performance 
enhancements. For example, if we used as keyword "instancif" ("instance 
if"), it could be used like that:

// condition is a class or a function
instancif(SomeClassOrFunction) void f1() {}
// condition is a member function
instancif(SomeClass::SomeFunction<int>) void f2() {}
 
// also useful for classes?
instancif(Something) class C1 {
  void f3();
  template <typename T>
  void f4(T);
  template <typename T>
  T f5();
  void f6();
};
 
// only for a class member
instancif(Something) void C1::f3() {}
// mixed with template
template <typename T>
instancif(SomeTemplateClass<T>) void C1::f4(T) {}
// also with template for condition
template <typename T, typename V>
instancif(SomeTemplateClass<V>) T C1::f5() { return {}; }
// and specialization
template <typename T>
instancif(SomeOtherTemplateClass<int, T>) void C1::f6() {}

The keyword is not useful for a library user, so I believe it should be 
placed in the same manner as the "inline" keyword before the implementation 
of the function.

So, do you have an opinion about that? Thanks.

Regards,
Adrien Hamelin

PS: I have a comment that says this could be mixed with the possible 
"static if".
PPS: the original blog post 
is https://aboutcpp.wordpress.com/2015/05/19/proposal-optimizing-out-useless-functions/

-- 

--- 
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

------=_Part_1863_781353863.1432370781921
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Hi,<div><br></div><div>I have written an idea I got to ext=
end the C++ language on my blog and have been advised to post it here, so h=
ere it is. The basic idea is to help the compiler remove functions that are=
 actually used but with no side effects. It does it automatically for simpl=
e functions, but it cannot always do it.</div><div>An example I have is wit=
h a signal system. Imagine it is like this:</div><div><br></div><div><div c=
lass=3D"prettyprint" style=3D"border: 1px solid rgb(187, 187, 187); word-wr=
ap: break-word; background-color: rgb(250, 250, 250);"><code class=3D"prett=
yprint"><div class=3D"subprettyprint"><span style=3D"color: #008;" class=3D=
"styled-by-prettify">template</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">&lt;</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy">size_t ID</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">&gt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br=
></span><span style=3D"color: #008;" class=3D"styled-by-prettify">class</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span =
style=3D"color: #606;" class=3D"styled-by-prettify">Sender</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">public</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">:</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"><br>&nbsp; </span><span style=3D"color: #800;" class=3D"styled-b=
y-prettify">// some code</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"><br>&nbsp; </span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">static</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify=
">void</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> sen=
d</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><=
span style=3D"color: #800;" class=3D"styled-by-prettify">/* parameters */</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">);</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">};</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br>&nbsp;<br></span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">template</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify">size_t ID</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">&gt;</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" class=3D"s=
tyled-by-prettify">class</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> </span><span style=3D"color: #606;" class=3D"styled-by-prett=
ify">Receiver</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><spa=
n style=3D"color: #008;" class=3D"styled-by-prettify">public</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">:</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br>&nbsp; </span><span style=3D"c=
olor: #800;" class=3D"styled-by-prettify">// some code</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">template</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #008=
;" class=3D"styled-by-prettify">typename</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=3D=
"styled-by-prettify">Function</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">&gt;</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"><br>&nbsp; </span><span style=3D"color: #008;" class=3D"styled=
-by-prettify">void</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> receive</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">(</span><span style=3D"color: #606;" class=3D"styled-by-prettify">Fun=
ction</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> f</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">);</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">};</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"><br><br></span><span style=3D"color=
: #800;" class=3D"styled-by-prettify">// Usage //////////////////////</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp;<br></=
span><span style=3D"color: #800;" class=3D"styled-by-prettify">// Elsewhere=
 in the code ------</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"><br></span><span style=3D"color: #606;" class=3D"styled-by-prettif=
y">Receiver</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>&lt;</span><span style=3D"color: #066;" class=3D"styled-by-prettify">0</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">&gt;</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> receiver</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp;<br></span><span s=
tyle=3D"color: #800;" class=3D"styled-by-prettify">// later...</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=
=3D"color: #606;" class=3D"styled-by-prettify">Sender</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color:=
 #066;" class=3D"styled-by-prettify">0</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">&gt;::</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">send</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">(</span><span style=3D"color: #800;" class=3D"styled-by-p=
rettify">/* parameters */</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">);</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"><br>&nbsp;<br></span><span style=3D"color: #800;" class=3D"styled-by=
-prettify">// later...</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"><br>receiver</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">.</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify">receive</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">([]</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span =
style=3D"color: #800;" class=3D"styled-by-prettify">/* parameters */</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"><br>&nbsp; </span><span style=3D"color: #800=
;" class=3D"styled-by-prettify">// something</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">});</span></div></code></div><div class=3D"line=
 number25 index24 alt2" style=3D"font-family: Consolas, 'Bitstream Vera San=
s Mono', 'Courier New', Courier, monospace; font-size: 15px; line-height: 1=
6.5px; color: rgb(55, 55, 55); outline: 0px !important; padding-right: 1em =
!important; padding-left: 1em !important; border-radius: 0px !important; bo=
ttom: auto !important; float: none !important; height: auto !important; lef=
t: auto !important; overflow: visible !important; position: static !importa=
nt; right: auto !important; top: auto !important; width: auto !important; b=
ox-sizing: content-box !important; direction: ltr !important; -webkit-box-s=
hadow: none !important; box-shadow: none !important; white-space: pre !impo=
rtant; background-image: none !important; background-attachment: initial !i=
mportant; background-size: initial !important; background-origin: initial !=
important; background-clip: initial !important; background-position: initia=
l !important; background-repeat: initial !important;"><br></div></div><div>=
Pretty simple, each signal is differentiated by an ID. When a signal needs =
to be sent, one has just to call the send() function and&nbsp;every receive=
rs that exist at that time will receive the signal and handle it when the r=
eceive() function is called.</div><div>With a GUI library, for example, a l=
ot of signals will be sent whether there is a receiver or not. But the send=
() function is not optimized out (at least in my test application with GCC =
and clang and -O3), so some CPU cycle are wasted when there are no receiver=
s. My idea is then a keyword that indicates that if a function or a class d=
oes not exist at link time, when the executable is build, the dependent fun=
ction calls can simply be removed from the program, with no side-effects, a=
nd some performance enhancements. For example, if we used as keyword "insta=
ncif" ("instance if"), it could be used like that:</div><div><br></div><div=
><div class=3D"prettyprint" style=3D"border: 1px solid rgb(187, 187, 187); =
word-wrap: break-word; background-color: rgb(250, 250, 250);"><code class=
=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #800;"=
 class=3D"styled-by-prettify">// condition is a class or a function</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"><br>instancif</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span s=
tyle=3D"color: #606;" class=3D"styled-by-prettify">SomeClassOrFunction</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"c=
olor: #008;" class=3D"styled-by-prettify">void</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> f1</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">()</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">{}</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"><br></span><span style=3D"color: #800;" class=3D"styled-by-prettify">//=
 condition is a member function</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"><br>instancif</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">(</span><span style=3D"color: #606;" class=3D"style=
d-by-prettify">SomeClass</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">::</span><span style=3D"color: #606;" class=3D"styled-by-pret=
tify">SomeFunction</span><span style=3D"color: #080;" class=3D"styled-by-pr=
ettify">&lt;int&gt;</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
 </span><span style=3D"color: #008;" class=3D"styled-by-prettify">void</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> f2</span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">()</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">{}</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"><br>&nbsp;<br></span><span style=3D"color: #8=
00;" class=3D"styled-by-prettify">// also useful for classes?</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"><br>instancif</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=
=3D"color: #606;" class=3D"styled-by-prettify">Something</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" =
class=3D"styled-by-prettify">class</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> C1 </span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"><br>&nbsp; </span><span style=3D"color: #008;" class=3D"styled-by-=
prettify">void</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> f3</span><span style=3D"color: #660;" class=3D"styled-by-prettify">();=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp;=
 </span><span style=3D"color: #008;" class=3D"styled-by-prettify">template<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span sty=
le=3D"color: #008;" class=3D"styled-by-prettify">typename</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> T</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">&gt;</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"><br>&nbsp; </span><span style=3D"color: #0=
08;" class=3D"styled-by-prettify">void</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> f4</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify">T</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">);</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&=
nbsp; </span><span style=3D"color: #008;" class=3D"styled-by-prettify">temp=
late</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><spa=
n style=3D"color: #008;" class=3D"styled-by-prettify">typename</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> T</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">&gt;</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br>&nbsp; T f5</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">();</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"><br>&nbsp; </span><span style=3D"color:=
 #008;" class=3D"styled-by-prettify">void</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> f6</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">();</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"><br></span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">};</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"><br>&nbsp;<br></span><span style=3D"color: #800;" class=3D"styled-by-pre=
ttify">// only for a class member</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br>instancif</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">(</span><span style=3D"color: #606;" class=3D"st=
yled-by-prettify">Something</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">v=
oid</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> C1</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify">f3</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">()</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">{}</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br></span><span style=3D"color: #800;" class=3D"st=
yled-by-prettify">// mixed with template</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">template</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">&lt;</span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">typename</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> T</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&=
gt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>ins=
tancif</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</s=
pan><span style=3D"color: #606;" class=3D"styled-by-prettify">SomeTemplateC=
lass</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify">T</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">&gt;)</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"col=
or: #008;" class=3D"styled-by-prettify">void</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> C1</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify">f4</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
">T</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">{}</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: =
#800;" class=3D"styled-by-prettify">// also with template for condition</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">template</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">typename</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> T</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-=
prettify">typename</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> V</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
&gt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>in=
stancif</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</=
span><span style=3D"color: #606;" class=3D"styled-by-prettify">SomeTemplate=
Class</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify">V</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">&gt;)</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> T C1</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify">f5</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">()</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">ret=
urn</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">{};</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">}</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #800;" c=
lass=3D"styled-by-prettify">// and specialization</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">template</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">&lt;</span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">typename</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> T</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">&gt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"><br>instancif</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">(</span><span style=3D"color: #606;" class=3D"styled-by-prettify">Some=
OtherTemplateClass</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">&lt;</span><span style=3D"color: #008;" class=3D"styled-by-prettify=
">int</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> T</span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">&gt;)</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"colo=
r: #008;" class=3D"styled-by-prettify">void</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> C1</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify">f6</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">()</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">{}</spa=
n></div></code></div><div class=3D"line number26 index25 alt1" style=3D"fon=
t-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, mon=
ospace; font-size: 15px; line-height: 16.5px; color: rgb(55, 55, 55); outli=
ne: 0px !important; padding-right: 1em !important; padding-left: 1em !impor=
tant; border-radius: 0px !important; bottom: auto !important; float: none !=
important; height: auto !important; left: auto !important; overflow: visibl=
e !important; position: static !important; right: auto !important; top: aut=
o !important; width: auto !important; box-sizing: content-box !important; d=
irection: ltr !important; -webkit-box-shadow: none !important; box-shadow: =
none !important; white-space: pre !important; background-image: none !impor=
tant; background-attachment: initial !important; background-size: initial !=
important; background-origin: initial !important; background-clip: initial =
!important; background-position: initial !important; background-repeat: ini=
tial !important;"><br></div></div><div>The keyword is not useful for a libr=
ary user, so I believe it should be placed in the same manner as the "inlin=
e" keyword before the implementation of the function.</div><div><br></div><=
div>So, do you have an opinion about that? Thanks.</div><div><br></div><div=
>Regards,</div><div>Adrien Hamelin</div><div><br></div><div>PS: I have a co=
mment that says this could be mixed with the possible "static if".</div><di=
v>PPS: the original blog post is&nbsp;https://aboutcpp.wordpress.com/2015/0=
5/19/proposal-optimizing-out-useless-functions/</div></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_1863_781353863.1432370781921--
------=_Part_1862_964800397.1432370781921--

.
