title: What is the purpose of std::function?
body: <p>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 .</p>
  
  <p>I was browsing through the standard library as I usually do and I get a remainder that <code>std::function</code> exist, but the thing is I can't figure out why I can possibly be interested in using <code>std::function</code>, 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 <code>std::function</code> ?</p>
  
  <p>For example in my case I was thinking about using a <code>map</code> or an <code>hash table</code> ( but the number of functions involved is really small anyway, 2-3 max for now ) with a pair composed of <code>tag</code> ( which represents the version/implementation of the file format ) + <code>functions</code>, and I was wondering why I can't just use <code>std::string</code> and functions pointers as the 2 types for each pair; and I also can't really understand why we have <code>std::function</code> in the standard library .</p>
  
  <p>I mean, when it's the case when you need a function that is unnamed and you need an object to describe its state ?</p>