Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
banachtarski
on April 27, 2020
|
parent
|
context
|
favorite
| on:
The Lost Art of Structure Packing (2018)
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.
shawxe
on April 27, 2020
|
next
[–]
To be clear, there are obviously different/better ways to handle this in C++. We're talking about K&R C here.
banachtarski
on April 27, 2020
|
parent
|
next
[–]
Right I mentioned "store size of the key on the map" as the second option for K&R/Ansi C.
saagarjha
on April 27, 2020
|
prev
[–]
The answer is wrong more because it relies on padding bytes having consistent values than a lack of templating.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: