vector of pointer to typical array of pointer

Hi forum,

I have declared an array of pointers as follows

 
std::vector<cl_event*> eventList;


Since i am not sure about the number of events i am going to add, the events are added in the following manner:

 
eventList.push_back(event1);


Now there is another third party API that does not take the vector in the function parameter, instead it takes const cl_event *event_list as one of the function's input parameter.

Is there any STL function that converts the stl vector to the typical array or i have to do it manually ?


Thanks
Sajjad

http://www.cplusplus.com/reference/vector/vector/data/

Navigated to from:

http://www.cplusplus.com/reference/vector/vector/

which is found in the reference section of this site (and also by googling std::vector.)
vector::data() was added in C++11.

You don't indicate what the duration of visibility to the array is by the third party API.
Keep in mind that if the API keeps the address of the array around after the call, and you push_back more events, vector may reallocate the array, thereby invalidating the address passed to the API.


Topic archived. No new replies allowed.