<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Feb 11, 2015 at 6:34 PM, Eric Fiselier <span dir="ltr"><<a href="mailto:eric@efcs.ca" target="_blank">eric@efcs.ca</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class="">>It's not yet completely clear whether Clang's (and GCC's) behavior is right here; there's an active core issue on how to handle this case.<br>
<br>
</span>GCC 4.8 and clang actually do the exact same thing on the example<br>
code.</blockquote><div><br></div><div>Right, that's why I said "(and GCC's)". =) EDG doesn't behave this way, FWIW.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">What behavior are you referring to exactly?<br></blockquote><div><br></div><div>The eager instantiation of the constexpr constructor that is used in an unevaluated operand.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Could you explain why the dependent type trick actually works? I'm<br>
unsure as to why clang thinks it can evaluate one set of template<br>
arguments but not the other even though it has essentially the same<br>
information when evaluating `tuple()`.<br></blockquote><div><br></div><div>Substituting into</div><div><br></div><div><span style="font-size:12.8000001907349px">  template <bool Dummy = true,</span><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">    class = typename std::enable_if<</span><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">         std::is_default_constructible<</span><span style="font-size:12.8000001907349px">T>::value</span><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">      && std::is_default_constructible<</span><span style="font-size:12.8000001907349px">U>::value</span><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">      && Dummy>::type</span><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">    ></span><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">  constexpr pair()</span><br style="font-size:12.8000001907349px"></div><div><span style="font-size:12.8000001907349px"><br></span></div><div><span style="font-size:12.8000001907349px">produces</span></div><div><span style="font-size:12.8000001907349px"><br></span></div><div><span style="font-size:12.8000001907349px">  template <bool Dummy = true,</span><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">    class = typename std::enable_if<</span><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">         std::is_default_constructible<</span><span style="font-size:12.8000001907349px">IllFormedDefaultImp>::value</span><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">      && std::is_default_constructible<IllFormedDefaultImp</span><span style="font-size:12.8000001907349px">>::value</span><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">      && Dummy>::type</span><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">    ></span><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">  constexpr pair()</span><br style="font-size:12.8000001907349px"></div><div><span style="font-size:12.8000001907349px"><br></span></div><div><span style="font-size:12.8000001907349px">Note that this triggers the instantiation of </span><span style="font-size:12.8000001907349px">std::is_default_constructible<</span><span style="font-size:12.8000001907349px">IllFormedDefaultImp>, even though it appears within a value-dependent expression.</span></div><div><span style="font-size:12.8000001907349px"><br></span></div><div><span style="font-size:12.8000001907349px">Both your and my rewrite avoid this by hiding the instantiation behind another template that has a dependent argument.</span></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Also is clang ever going to outsmart this trick and realize<br>
`dependent<is_default_constructible<_Tp>, Dummy>` is not actually<br>
dependent on anything in this context? (ie on a default constructor)<br></blockquote><div><br></div><div>That's very unlikely; we'd have to use the fact that this is a constructor to show that 'Dummy' is always 'true', and then use that to determine that there are no valid specializations of the constructor template. It's not even clear that this would be permissible under the guise of the "a template that has no valid specializations is ill-formed" rule. Plus this would break lots of real-world code, so we wouldn't do it even if we could.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Thanks for your input<br>
<span class=""><font color="#888888"><br>
/Eric<br>
</font></span><div class=""><div class="h5"><br>
<br>
<br>
<br>
<br>
On Wed, Feb 11, 2015 at 7:12 PM, Richard Smith <<a href="mailto:richard@metafoo.co.uk">richard@metafoo.co.uk</a>> wrote:<br>
> ================<br>
> Comment at: include/type_traits:2649-2652<br>
> @@ -2648,1 +2648,6 @@<br>
><br>
> +template <class _Tp, bool><br>
> +struct _LIBCPP_TYPE_VIS_ONLY __dependent_is_default_constructible<br>
> +    : public is_default_constructible<_Tp><br>
> +    {};<br>
> +<br>
> ----------------<br>
> Is it worth generalizing / simpilfying this:<br>
><br>
>     template <class _Tp, bool> struct __dependent : public _Tp {};<br>
><br>
> (Usage: `__dependent<is_default_constructible<_Tp>, Dummy>::value`)<br>
><br>
> <a href="http://reviews.llvm.org/D7569" target="_blank">http://reviews.llvm.org/D7569</a><br>
><br>
> EMAIL PREFERENCES<br>
>   <a href="http://reviews.llvm.org/settings/panel/emailpreferences/" target="_blank">http://reviews.llvm.org/settings/panel/emailpreferences/</a><br>
><br>
><br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</div></div></blockquote></div><br></div></div>