<br><br><div class="gmail_quote">On Sun, Feb 19, 2012 at 5:48 PM, Robert Ramey <span dir="ltr">&lt;<a href="mailto:ramey@rrsd.com">ramey@rrsd.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<u></u>





<div bgcolor="#ffffff"><div class="im">
<div>Ovanes Markarian wrote:<br>&gt; On Fri, Feb 17, 2012 at 9:40 PM, Robert 
Ramey &lt;<a href="mailto:ramey@rrsd.com" target="_blank">ramey@rrsd.com</a>&gt; wrote:<br>&gt; <br>&gt; [...]<br>&gt; <br>&gt; 
Andre Alex... gave a talk at &quot;Going Native&quot;� proposing<br>&gt; a &quot;static 
if&quot; for this case.� But I don&#39;t see the necessity for<br>&gt; for this 
since I would assume that the compiler<br>&gt; just optimises away the &quot;dead&quot; 
code.� I&#39;ve compiled<br>&gt; the above and it seems to do what I want 
but<br>&gt; still I wonder.<br>&gt; <br>&gt; <br>&gt; Robert, I see Andrey&#39;s 
proposal aimed to replace the enable_if which<br>&gt; is based on SFINAE and 
greatly simplify the metaprogramming<br>&gt; machinery. The code you present if 
fine and it might be optimized<br>&gt; away by the compiler, but it might 
produce compilation errors, since<br>&gt; all runtime branches of if-statement 
must be compilable without<br>&gt; errors. SFINAE aimes to work around it, like 
we can enable some<br>&gt; special treatment if the provided code &quot;would 
compile&quot; without<br>&gt; errors.�</div>
<div>�</div>
</div><div><font face="Arial">Basically this example is the first slide in 
Andrei&#39;s talk.� The purpose</font></div>
<div><font face="Arial">was to introduce a use case for the need for 
&quot;static if&quot;.� To my mind</font></div>
<div><font face="Arial">it failed in its purpose since a &quot;normal if&quot; 
already does that.� It&#39;s even</font></div>
<div><font face="Arial">worse - Andrei ruminated on the question as to what 
should be done</font></div>
<div><font face="Arial">with the &quot;dead&quot; branch.� i.e. should it be 
skipped entirely or actually</font></div>
<div><font face="Arial">compiled - he left that question open.� It 
seemed to me that for this</font></div>
<div><font face="Arial">case, the whole question could be addressed by 
adding language</font></div>
<div><font face="Arial">to the standard that a compiler should elminate 
code for which</font></div>
<div><font face="Arial">it can be determined at compile time will never be 
run.�</font></div></div></blockquote><div>[...]</div><div>Robert, somehow I do not get your proposal. How do you consider an if-branch, which is not going to compile, i.e. compilation error. Do you propose, to ignore that branch and just state: &quot;OK, if there is a compilation error, that must be eliminated without any errors to the end-user&quot;. I don&#39;t think this can work. Therefore there should be a special language construct, which states: &quot;if there is a compilation error, than it is safe to be ignored during the compilation&quot;</div>

<div><br></div><div>[...]</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div bgcolor="#ffffff"><div><div class="im">
<div><font face="Arial"></font><font face="Arial"></font><br>&gt; On 
the other hand using static if we might inspect the exposed type<br>&gt; system 
of some type T. Let&#39;s say we would like to unify some<br>&gt; different types 
using a traits class. Out traits class should expose<br>&gt; value_type of the 
inspected type (say we have a boost::shared_ptr and<br>&gt; std::vector as 
input). boost::shared_ptr contains a typedef of<br>&gt; underlying type which is 
named element_type and std::vector names the<br>&gt; underlying type value_type. 
Out traits type should homogenize these<br>&gt; two types and provide a 
value_type member, which contains the<br>&gt; underlying type of either 
shared_ptr or std::vector. It can be easily<br>&gt; 
&quot;calculated/specialized/inspected&quot; with static if construct. How are<br>&gt; you 
going to solve this problem with the runtime if without using<br>&gt; enable_if 
, overloads and template specializations?</div>
<div>�</div>
</div><div><font face="Arial">Hmmm - a small code example might make this easier 
to understand</font></div>
<div><font face="Arial"></font>�</div></div></div></blockquote><div>[...]</div><div>I am a little bit in hurry today, but will submit the example tomorrow.</div><div><br></div><div><br></div><div>With Kind Regards,</div>

<div>Ovanes</div><div>�</div></div>