c++ - 在 WaitForMultipleObjects() 中使用 std::vector

标签 c++ vector waitformultipleobjects

我有一个句柄对象的std::vector。我必须等待这些句柄对象才能在 WaitForMultipleObjects 函数中使用。因为它是一个 vector ,所以在 WaitForMultipleObjects 中使用它时出现错误:

std::vector<HANDLE> events;
// ...
WaitForMultipleObjects(events.size(), events, true, INFINITE);

有什么办法吗?

最佳答案

最好,如果你有最新版本的 STL,你应该使用:

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

对于较旧的 STL,如果 .data() 不可用作 vector 上的方法,则可以使用 &events[0]。

关于c++ - 在 WaitForMultipleObjects() 中使用 std::vector,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11097059/

相关文章:

c++ - 使用IOS成员(member)进行格式化

c++ - C2061 - 循环依赖

c++ - 将内联函数的不同实现链接到一个可执行文件中的情况如何分类?

c++ - 在顶部插入时双端队列是否提供 O(1) 复杂度

c++ - Boost.Thread 类 CEvent 行为

c++ - 使用 IOCP 检测子进程的退出/失败 - C++ - Windows

c++ - 将 C++11 move 语义应用于绑定(bind)函数

c++ - 试图从 Derived* 的 vector 中分配 Base* 的 vector

c++ - 在访问存储在 vector<base*> 中的已知派生类对象时使用 dynamic_cast 或 static_cast 有什么问题?