Lets say I have a structure
struct s
{
std::deque<Object> q; //won't work with C library
}
If the structure with std::deque is initialized using C library then it wouldn’t work.
struct s
{
std::vector<Object> v; //would work with C library
}
However, this structure with std::vector would work with C library.
I think this is because the elements in deque are not contiguous whereas the elements in vector are contiguous. I think this might be a reason but not sure.
Neither version of
Swill work with a C library.This is because C does not have any concept of how classes are layed out (or even what is in them).
Vector can be used with C library if you pass the address of an element. Because all the elements are in contiguous memory it looks like a normal pointer and thus any C function that takes a pointer will work.