diff --git a/core/unit_test/TestComplex.hpp b/core/unit_test/TestComplex.hpp index e580fb50343..c9e0225011d 100644 --- a/core/unit_test/TestComplex.hpp +++ b/core/unit_test/TestComplex.hpp @@ -573,15 +573,18 @@ TEST(TEST_CATEGORY, complex_structured_bindings) { ASSERT_EQ(ri, 7.); // get const rvalue - static_assert(std::is_same_v( - const_cast(Z(11., 13.)))), - Z::value_type const &&>); - static_assert(std::is_same_v( - const_cast(Z(11., 13.)))), - Z::value_type const &&>); - auto &&[crr, cri] = const_cast(Z(11., 13.)); - ASSERT_EQ(crr, 11.); - ASSERT_EQ(cri, 13.); + auto rc = []() -> Z const && { + static const Z zz(11., 13.); + return std::move(zz); + }; + static_assert( + std::is_same_v(rc())), Z::value_type const &&>); + static_assert( + std::is_same_v(rc())), Z::value_type const &&>); + + auto &&[crr, cri] = rc(); + ASSERT_EQ(crr, rc().real()); + ASSERT_EQ(cri, rc().imag()); // swap real and imaginary const Z z0 = l;