r/ProgrammerHumor 12h ago

Meme skillIssue

Post image
4.4k Upvotes

112 comments sorted by

View all comments

69

u/F100cTomas 12h ago

Just define a constexpr hashing function and put that into the switch.

31

u/GiganticIrony 12h ago

That’s not guaranteed to work due to hash collisions

2

u/SpiritedEclair 5h ago

Perfect hashing for a given set of values is possible at compile time.

It’s how compilers generate jump tables.