[libcxx-commits] [PATCH] D96523: [libc++] Rewrite the tuple constructors to be strictly Standards conforming
Zoe Carver via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Feb 16 15:07:42 PST 2021
zoecarver added a comment.
In D96523#2566911 <https://reviews.llvm.org/D96523#2566911>, @ldionne wrote:
> In D96523#2564329 <https://reviews.llvm.org/D96523#2564329>, @zoecarver wrote:
>
>> Also, I just realized that we can use fold expressions here (on all supported compilers even in C++03 mode). I bet that would be faster/cleaner than instantiating all the `_And`s.
>
> So we can't actually use fold expressions because they don't short-circuit instantiations. A fold expression like `trait<args>::value && ...` gets expanded to `trait<arg0>::value && trait<arg1>::value && trait<arg2>::value && <etc>`. While the evaluation of the boolean is short-circuited, the instantiation of `trait<argn>::value` is not, which is what we're trying to do here. As a result, if for example `trait<arg2>::value` causes a hard error, it will be instantiated even if `trait<arg0>::value` instantiates fine and evaluates to `false`. Does that make sense?
Hmm. I understand what you're saying, but I think that's only the case if it's a static var. If it's actually part of the type (i.e., it's used to specialize a `_BoolConstant`), I think it works the same way. Here's an example. <https://godbolt.org/z/Mdd5s1>
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D96523/new/
https://reviews.llvm.org/D96523
More information about the libcxx-commits
mailing list