title: How can I create a std::function with a custom allocator?
body: <p>To save some code lets say I have a custom allocator named <code>MyAlloc</code> which I have successfully used with a <code>std::vector&lt;int&gt;</code> as follows:</p>
  
  <pre><code>std::vector&lt;int,MyAlloc&lt;int&gt;&gt; vec;
  </code></pre>
  
  <p>now I want to save a lambda in a std::function using the custom allocator, how do I do it?</p>
  
  <p>My failed attempt:</p>
  
  <pre><code>int i[100];
  std::function&lt;void(int)&gt; f(MyAlloc&lt;void/*what to put here?*/&gt;{},[i](int in){
      //...
  });
  </code></pre>
  
  <p><strong>Update:</strong> allocators in std::function have been <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0302r0.html" rel="noreferrer" title="depricated">deprecated</a></p>