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