News for hackers. Stuff that matters.
Re:The Lost Art of Structure Packing (2018) by banachtarski on Monday April 27, 2020 @11:37AM (#22996830)
Wrong answer. This is brittle and relies on the memory always being initialized correctly and will be prone to all sorts of issues in the wild. Better is just either templatize on the key type or store the size on the map.
Re:The Lost Art of Structure Packing (2018) by shawxe on Monday April 27, 2020 @11:44AM (#22996917)
To be clear, there are obviously different/better ways to handle this in C++. We're talking about K&R C here.
Re:The Lost Art of Structure Packing (2018) by banachtarski on Monday April 27, 2020 @03:11PM (#22998909)
Right I mentioned "store size of the key on the map" as the second option for K&R/Ansi C.
Re:The Lost Art of Structure Packing (2018) by saagarjha on Monday April 27, 2020 @11:43AM (#22996907)
The answer is wrong more because it relies on padding bytes having consistent values than a lack of templating.