title: Capturing array of vectors in lambda makes elements const
body: <pre><code>#include &lt;vector&gt;                                                               
  
  void main() {                                                                   
    std::vector&lt;int&gt; test[2];                                                     
    auto funct = [test](){ test[0].push_back(1); };                               
    funct();                                                                      
  } 
  </code></pre>
  
  <p>As a result I get</p>
  
  <blockquote>
    <p>main.cc:5:45: error: passing ‘const std::vector’ as ‘this’ argument of ‘void std::vector&lt;_Tp, _Alloc>::push_back(std::vector&lt;_Tp, _Alloc>::value_type&amp;&amp;) [with _Tp = int; _Alloc = std::allocator; std::vector&lt;_Tp, _Alloc>::value_type = int]’ discards qualifiers [-fpermissive]
       auto funct = test{ test[0].push_back(1); };</p>
  </blockquote>
  
  <p>How can I capture <code>test</code> pointer without making its values <code>const</code>? Is there any other way other than making it a <code>vector&lt;vector&lt;int&gt;&gt;</code>? Why is it even becoming a const?</p>