Skip to content

Commit

Permalink
Workaround for VS16 not liking casting to r-value reference to const
Browse files Browse the repository at this point in the history
  • Loading branch information
nliber committed May 31, 2024
1 parent d48b802 commit 54781cc
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions core/unit_test/TestComplex.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -573,15 +573,18 @@ TEST(TEST_CATEGORY, complex_structured_bindings) {
ASSERT_EQ(ri, 7.);

// get const rvalue
static_assert(std::is_same_v<decltype(Kokkos::get<0>(
const_cast<Z const &&>(Z(11., 13.)))),
Z::value_type const &&>);
static_assert(std::is_same_v<decltype(Kokkos::get<1>(
const_cast<Z const &&>(Z(11., 13.)))),
Z::value_type const &&>);
auto &&[crr, cri] = const_cast<Z const &&>(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<decltype(Kokkos::get<0>(rc())), Z::value_type const &&>);
static_assert(
std::is_same_v<decltype(Kokkos::get<1>(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;
Expand Down

0 comments on commit 54781cc

Please sign in to comment.