Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.


To be clear, there are obviously different/better ways to handle this in C++. We're talking about K&R C here.


Right I mentioned "store size of the key on the map" as the second option for K&R/Ansi C.


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: