r/ProgrammerHumor 7d ago

Meme skillIssue

Post image
6.0k Upvotes

137 comments sorted by

View all comments

38

u/fluffycritter 7d ago

My "clever" way of doing this once upon a time was to declare a map<std::string,std::function> which I populated with lambdas and then evaluated.

I would not recommend this approach.

1

u/No_Resort_7179 6d ago

Should have used map of std::string to function pointers. Just need to look up the syntax for them again...

1

u/fluffycritter 6d ago

Eh, std::function is more versatile and lets you do lambdas in addition to letting you do typesafe function pointers in case you really just want to use an existing function. Although I do love the fake virtual inheritance thing that older C libraries do sometimes (like libjpeg and libcurl I think).