If a struct in #cplusplus is trivally copyable, should the copy guarantee that it is also trivially comparable (ie, memcmp())?
Turns out it's not. There isn't really a concept of "trivially comparable" as far as I can tell.
The tricky part is when you have empty structs. Compiler doesn't have to generate any actual mov assembly for empty structs. But when you sizeof() an empty struct, it must be 1 according to the standard.
-
-
I haven't tested enough, but it seems that for other cases (ie, non-empty structs) it works out okay.
Näytä tämä ketju -
Perhaps the giveaway to the lack of guarantee is that the compiler will automatically generate operator=(), but not operator==().
Näytä tämä ketju
Keskustelun loppu
Uusi keskustelu -
Lataaminen näyttää kestävän hetken.
Twitter saattaa olla ruuhkautunut tai ongelma on muuten hetkellinen. Yritä uudelleen tai käy Twitterin tilasivulla saadaksesi lisätietoja.