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.
int i_;
public:
constexpr explicit X(int i) : i_(i) {}
- constexpr X(X&& x) : i_(std::exchange(x.i_, 0)) {}
+ constexpr X(X&& x) : i_(x.i_) { x.i_ = 0; }
TEST_CONSTEXPR_CXX20 ~X() {i_ = 0;}
friend constexpr bool operator==(const X& x, const X& y) {return x.i_ == y.i_;}
};