title: Is it good style to use lambda functions to define very small helper functions?
body: <p>As a silly example, let's say I have a function <code>int f(vector&lt;int&gt; v)</code>, and for some reason, I need to do a couple of operations on <code>v</code> several times in <code>f</code>. Instead of putting a helper function elsewhere (which could increase clutter and hurt readability), what are the advantages and disadvantages to doing something like this (efficiency, readability, maintainability, etc.):</p>
  
  <pre><code>int f(vector&lt;int&gt; v)
  {
      auto make_unique  = [](vector&lt;int&gt; &amp;v)
      {
          sort(begin(v), end(v));
          auto unique_end = unique(begin(v), end(v));
          v.erase(unique_end, end(v));
      };
      auto print_vector = [](vector&lt;int&gt; const &amp;v)
      {
          copy(begin(v), end(v), ostream_iterator&lt;int&gt;(cout, " "));
          cout &lt;&lt; endl;
      };
  
     make_unique (v);
     print_vector(v);
     // And then the function uses these helpers a few more times to justify making
     // functions...
  }
  </code></pre>
  
  <p>Or is there some preferred alternative?</p>