I have a class like so:
class A {
std::vector<
std::vector<
std::pair<
uint32_t, std::reference_wrapper<std::vector<uint8_t>>>>>
table;
};
In the constructor of the class I resize the vector, like so table.resize(indexSize)
but when I try to push items in I get an error:
void A::insertItem(const uint32_t &g, const vector<uint8_t> &point)
{
this->table[g % this->indexSize].push_back(make_pair(g, point));
}
I guess when I resize I need to pass a constructor of some sort?
The error I get is:
no instance of overloaded function "std::vector<_Tp, _Alloc>::push_back [with _Tp=std::pair<uint32_t, std::reference_wrapper<std::vector<uint8_t, std::allocator<uint8_t>>>>, _Alloc=std::allocator<std::pair<uint32_t, std::reference_wrapper<std::vector<uint8_t, std::allocator<uint8_t>>>>>]" matches the argument list -- argument types are: (std::pair<uint32_t, std::vector<uint8_t, std::allocator<uint8_t>>>) -- object type is: std::vector<std::pair<uint32_t, std::reference_wrapper<std::vector<uint8_t, std::allocator<uint8_t>>>>, std::allocator<std::pair<uint32_t, std::reference_wrapper<std::vector<uint8_t, std::allocator<uint8_t>>>>>>
This example is functional:
The second argument of your pair have a constructor that needs an argument.