I want to use vectors to store two variables, integers and data. My initial thought was to store the data as a paired vector sort of like:
typedef std::vector<pair <const UInt8_T *, int > > MyVector;
// store the data to the vector
// data that is passed into a function as
const UInt8_T* pBuff and int nLen
myVector.push_back(pair<const UInt8_T*, int(pBuff, nLen));
but I noticed when I read the data back using:
for (vector<pair <const UInt8_T *, intT > >::const_iterator It = myVector.begin(); It != myVector.end(); It++)
const UInt8_T * rtData = It->first;
const UInt8_T * rtData = (*It).first;
rtData does not match the data that is passed in via the push_back call.
I am assuming I need to do some kind of new or something to hold the data instead of just a pointer to the data for the data being passed in as 'buff' might be released at some time before the call to the for loop, I am just not sure how to do the 'new' with a vector of buf data. Also I was thinking maybe I have to do a class or structure like:
const UInt8_T * data,
but then I still would have to do some kind of new and delete for the memory.
I would like some examples and/or suggestions how to accomplish saving both items, the data in the buffer and the buffer length via a vector type.