[libc++] Workaround non-constexpr std::exchange pre C++20
authorLouis Dionne <ldionne.2@gmail.com>
Tue, 13 Jul 2021 14:48:54 +0000 (10:48 -0400)
committerLouis Dionne <ldionne.2@gmail.com>
Tue, 13 Jul 2021 14:51:03 +0000 (10:51 -0400)
commit0da95a5cf2691c8e01ae02f108487c397ab7e0ce
treec3eb15a6cf15422ce435169e65b3bbd1c5fe7fdb
parentc5ad8bb8d41018ba58490873e95cc841d9276702
[libc++] Workaround non-constexpr std::exchange pre C++20

std::exchange is only constexpr in C++20 and later. We were using it
in a constructor marked unconditionally constexpr, which caused issues
when building with -std=c++17.

The weird part is that the issue only showed up when building on the
arm64 macs, but that must be caused by the specific version of Clang
used on those. Since the code is clearly wrong and the fix is obvious,
I'm not going to investigate this further.
libcxx/test/std/utilities/optional/optional.object/optional.object.ctor/explicit_optional_U.pass.cpp