diff --git a/tdutils/td/utils/common.h b/tdutils/td/utils/common.h index a54d969c1..7ee8e621a 100644 --- a/tdutils/td/utils/common.h +++ b/tdutils/td/utils/common.h @@ -113,11 +113,11 @@ class As { As(void *ptr) : ptr_(ptr) { } As(As &&) = default; - const As &operator=(const As &new_value) const { + As &operator=(const As &new_value) && { memcpy(ptr_, new_value.ptr_, sizeof(T)); return *this; } - const As &operator=(const T new_value) const { + As &operator=(const T new_value) && { memcpy(ptr_, &new_value, sizeof(T)); return *this; } diff --git a/tdutils/test/misc.cpp b/tdutils/test/misc.cpp index 1d952cd6b..66b06649d 100644 --- a/tdutils/test/misc.cpp +++ b/tdutils/test/misc.cpp @@ -593,6 +593,8 @@ TEST(Misc, As) { ASSERT_EQ(123, as((const char *)buf)); ASSERT_EQ(123, as((char *)buf)); char buf2[100]; + //auto x = as(buf2); + //x = 44342; //CE as(buf2) = as(buf); ASSERT_EQ(123, as((const char *)buf2)); ASSERT_EQ(123, as((char *)buf2));