[PATCH] [libc++] Try and prevent evaluation of `is_default_constructible` on tuples default constructor if it is not needed.

Eric Fiselier eric at efcs.ca
Wed Feb 11 18:34:52 PST 2015


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

GCC 4.8 and clang actually do the exact same thing on the example
code. What behavior are you referring to exactly?

Could you explain why the dependent type trick actually works? I'm
unsure as to why clang thinks it can evaluate one set of template
arguments but not the other even though it has essentially the same
information when evaluating `tuple()`.

Also is clang ever going to outsmart this trick and realize
`dependent<is_default_constructible<_Tp>, Dummy>` is not actually
dependent on anything in this context? (ie on a default constructor)

Thanks for your input

/Eric





On Wed, Feb 11, 2015 at 7:12 PM, Richard Smith <richard at metafoo.co.uk> wrote:
> ================
> Comment at: include/type_traits:2649-2652
> @@ -2648,1 +2648,6 @@
>
> +template <class _Tp, bool>
> +struct _LIBCPP_TYPE_VIS_ONLY __dependent_is_default_constructible
> +    : public is_default_constructible<_Tp>
> +    {};
> +
> ----------------
> Is it worth generalizing / simpilfying this:
>
>     template <class _Tp, bool> struct __dependent : public _Tp {};
>
> (Usage: `__dependent<is_default_constructible<_Tp>, Dummy>::value`)
>
> http://reviews.llvm.org/D7569
>
> EMAIL PREFERENCES
>   http://reviews.llvm.org/settings/panel/emailpreferences/
>
>



More information about the cfe-commits mailing list