title: How to deduce const and non-const type without duplicating functions?
body: <p>Let's say I have this function: (which pretty much runs a function on each value in container, and then returns a vector of the result of each iteration)</p>
  
  <pre><code>#include &lt;vector&gt;
  using std::vector;
  
  template&lt;class F, class V&gt;
  auto vmap(const F &amp;f, const V &amp;v) -&gt; vector&lt;decltype(f(v[0]))&gt; {
      vector&lt;decltype(f(v[0]))&gt; result;
      result.reserve(v.size());
      for (auto &amp;p : v)
          result.push_back(f(p));
      return result;
  }
  </code></pre>
  
  <p>I can't call it like this:</p>
  
  <pre><code>vector&lt;int&gt; vint = {1,2,3,4,5};
  vmap([](auto &amp;p) {return p++;},vint);
  </code></pre>
  
  <p>Because the parametered <code>vector</code> is <code>const</code>, to make it happen I will have to create two <code>vmap</code> that get non-<code>const</code> <code>V</code> and one that is <code>const</code>.</p>
  
  <p>It starts to feel too much when there are multiple containers/<code>vector</code>s passed to a function, because it makes me write <code>2^containers_count</code> functions.</p>
  
  <p>Is there any(-dirty but working) solution for this?</p>