I have a vector of binary data used by some middleware
std::vector<uint> data
The data inside this vector maps to a class Foo
basically like that:
|uint|uint|uint|uint|uint|uint|uint|uint|uint|
| F o o | F o o | F o o |
Using a custom placement allocator (as described here Can I use an std::vector as a facade for a pre-allocated (raw) array?) I can now map the memory of the first vector to a vector of type std::vector<Foo>
But if I operate on the second vector the size of the first one is not updated.
Another approach would be to encapsulate the first vector std::vector<uint8>
in a custom container which behaves like a std::vector<Foo>
but this is a lot of effort (and I cannot use Boost).
Any ideas for an elegant solution?