[libcxx-commits] [PATCH] D96523: [libc++] Rewrite the tuple constructors to be strictly Standards conforming

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Feb 16 14:50:23 PST 2021

ldionne added a comment.

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?

  rG LLVM Github Monorepo



More information about the libcxx-commits mailing list