title: C++11: In what order are lambda captures destructed?
body: <p>Let's say I have two local smart pointers, <code>foo</code> and <code>bar</code>.</p>
  
  <pre><code>shared_ptr&lt;Foo&gt; foo = ...
  shared_ptr&lt;Bar&gt; bar = ...
  </code></pre>
  
  <p>These smart pointers are wrappers around resources that for some reason must be destructed in the order <code>foo</code>, then <code>bar</code>.</p>
  
  <p>Now I want to create a lambda that uses <code>foo</code> and <code>bar</code>, but outlives the scope containing them. So I'd capture them by value, like this:</p>
  
  <pre><code>auto lambda = [foo, bar]() { ... };
  </code></pre>
  
  <p>This creates copies of <code>foo</code> and <code>bar</code> within the function object. When the function object is destructed, these copies will be destructed, as well, but I care about the order in which this happens. So my question is:</p>
  
  <p>When a lambda object is destructed, in what order are its by-value captures destructed? And how can I (hopefully) influence this order?</p>