Use std::vector in WaitForMultipleObjects()

c++, vector, waitformultipleobjects

Solution

Preferably, if you've got an up to date version of STL, you should use:

WaitForMultipleObjects(events.size(), events.data(), true, INFINITE);

With older STL's, you can use &events[0] if .data() isn't available as a method on vector.

Problem

I have an `std::vector` of handle objects. I have to wait on these handle objects for using in the `WaitForMultipleObjects` function. Since it's a vector, I am getting an error while using it in `WaitForMultipleObjects`: ``` std::vector<HANDLE> events; // ... WaitForMultipleObjects(events.size(), events, true, INFINITE); ``` Is there any way to do this?

Original source

Related problems