Avoid eager template instantiation caused by the variant narrowing checks.
authorEric Fiselier <eric@efcs.ca>
Sun, 14 Jul 2019 18:21:15 +0000 (18:21 +0000)
committerEric Fiselier <eric@efcs.ca>
Sun, 14 Jul 2019 18:21:15 +0000 (18:21 +0000)
commit194b337f3327691ee88007061c71225c934b3af0
treeab6e8e7224881de0e09d93c23f7321ff83776ece
parent57190b3974fbc07cdb5b61aeaf023de94c2afe7e
Avoid eager template instantiation caused by the variant narrowing checks.

The standard disallows narrowing conversions when constructing a variant.
This is checked by attempting to perform braced initialization of the
destination type from the argument type. However, braced initialization
can force the compiler (mostly clang) to eagerly instantiate the
constructors of the destintation type -- which can lead to errors in
a non-immediate context.

However, as variant is currently specified, the narrowing checks only
observably apply when the destination type is arithmetic. Meaning we can
skip the check for class types. Hense avoiding the hard errors.

In order to cause fewer build breakages, this patch avoids the narrowing
check except when the destination type is arithmetic.

llvm-svn: 366022
libcxx/include/variant
libcxx/test/std/utilities/variant/variant.variant/variant.ctor/T.pass.cpp