I was reasoning about how to write and design several functions that are supposed to deal with a specific file format which can possibly have different implementations and different versions, and each one needs a different way of decoding such information from the file .
I was browsing through the standard library as I usually do and I get a remainder that std::function exist, but the thing is I can't figure out why I can possibly be interested in using std::function, one of the first rules when programming in C and C++ is that if you don't have to refer to things you don't necessarily have to name them, and you can get unnamed data structures and unnamed/lambda functions, but functions usually have a name, and the type for a lambda is still implementation defined as far as I can remember, so what is the need for std::function ?
For example in my case I was thinking about using a map or an hash table ( but the number of functions involved is really small anyway, 2-3 max for now ) with a pair composed of tag ( which represents the version/implementation of the file format ) + functions, and I was wondering why I can't just use std::string and functions pointers as the 2 types for each pair; and I also can't really understand why we have std::function in the standard library .
I mean, when it's the case when you need a function that is unnamed and you need an object to describe its state ?