I have a problem similar to the one mentioned in the question Convert vector of vector to pointer of pointer.
The only difference is that I have to use booleans instead of shorts.
But if I compile this code:
#include <vector>
/* C like api */
void foo(bool **psPtr, const int x, const int y);
int main()
{
const int x = 2, y = 3;
std::vector<std::vector<bool>> vvsVec(x, std::vector<bool>(y, 0));
std::vector<bool *> vpsPtr(x, nullptr);
/* point vpsPtr to the vector */
int c = 0;
for (auto &vsVec : vvsVec)
vpsPtr[c++] = vsVec.data();
/* api call */
foo(vpsPtr.data(), x, y);
return 0;
}
I get the following error:
./dummy/main.cpp:15: error: assigning to '__gnu_cxx::__alloc_traits<std::allocator<bool *> >::value_type' (aka 'bool *') from incompatible type 'void'
and
./dummy/main.cpp:15: error: void value not ignored as it ought to be vpsPtr[c++] = vsVec.data();
Please, can someone explain me what I'm doing wrong and how to fix this?
Thanks.
Aucun commentaire:
Enregistrer un commentaire