I've created this vector, which has buffers:
std::vector<std::unique_ptr<locked_buffer<std::pair<int, std::vector<std::vector<unsigned char>>>>>> v1;
Then, I fill this vector with n
buffers and this buffers have aux
elements. n
is an int number which is an argument. aux
is another argument that is an int type too.
for(int i=0; i<n; i++){
v1.push_back(std::unique_ptr<locked_buffer<std::pair<int,std::vector<std::vector<unsigned char>>>>> (new locked_buffer<std::pair<int, std::vector<std::vector<unsigned char>>>>(aux)));
}
But when I try to access to each buffer of the vector I can't, because I haven't got clear how can I access to a specific element of a vector structure:
v1[0].put(image, false);
The compilation error that I've got is the following one (The put
function is defined on my custom locked_buffer
structure):
error: ‘_gnu_cxx::_alloc_traits<std::allocator<std::unique_ptr<locked_buffer<std::pair<int, std::vector<std::vector<unsigned char> > > > > > >::value_type {aka class std::unique_ptr<locked_buffer<std::pair<int, std::vector<std::vector<unsigned char> > > > >}’ has no member named ‘put’
v1[i].put(image, false);
Thanks.
v1[0]
is aunique_ptr<locked_buffer<...>>
. In order to call a method on the containedlocked_buffer
, you need to dereference theunique_ptr
, i.e.or