diff --git a/include/gridtools/common/tuple.hpp b/include/gridtools/common/tuple.hpp index 5e772ecf4..1fc522522 100644 --- a/include/gridtools/common/tuple.hpp +++ b/include/gridtools/common/tuple.hpp @@ -235,8 +235,6 @@ namespace gridtools { tuple(tuple const &) = default; tuple(tuple &&) = default; - tuple &operator=(tuple const &) = default; - tuple &operator=(tuple &&) = default; constexpr GT_FUNCTION tuple(T const &arg) noexcept : m_value(arg) {} @@ -260,6 +258,15 @@ namespace gridtools { swap(m_value, other.m_value); } + constexpr GT_FUNCTION tuple &operator=(tuple const &other) noexcept { + m_value = other.m_value; + return *this; + } + constexpr GT_FUNCTION tuple &operator=(tuple &&other) noexcept { + m_value = std::move(other.m_value); + return *this; + } + template , int> = 0> constexpr GT_FUNCTION tuple &operator=(tuple const &src) noexcept { m_value = src.m_value; diff --git a/tests/unit_tests/common/test_tuple.cpp b/tests/unit_tests/common/test_tuple.cpp index 8f699ca72..85f44c371 100644 --- a/tests/unit_tests/common/test_tuple.cpp +++ b/tests/unit_tests/common/test_tuple.cpp @@ -226,6 +226,15 @@ namespace gridtools { EXPECT_EQ(1, get<0>(testee)); } + TEST(onetuple, copy_assign_nested_ref) { + int src_int = 1; + int dst_int = 0; + tuple> src = {{src_int}}; + tuple> testee = {{dst_int}}; + testee = src; + EXPECT_EQ(1, get<0>(get<0>(testee))); + } + TEST(tuple, move_assign) { tuple testee; auto &res = testee = tuple{move_only{47}, move_only{2}};