我想知道是否可以使用结构作为promise的返回类型。我查看了C++参考资料,其中没有任何关于promise类型限制的说明。我能找到的所有示例都使用带有int、long、double、string类型的promises,但从不使用struct。它应该可以工作,但我一直有这样的错误:
k.cpp: In function ‘void DoSomeWork(int, std::promise</
我想要做的是从每个线程返回一个值。但是,它有此异常消息。libc++abi.dylib: terminating with uncaught exception of type std::__1::future_error: Operation not permitted代码看起来是这样的。::move(promises)));MyFunction看起来是这样的。(classObj);如果我使用一个线程,那么它可以正常工作,没有异常消息。
在抛出线程函数中的异常后,我会得到一个错误。terminate called after throwing an instance of 'std::future_error'函数正常工作,直到它认为异常为止以下是我的简化代码:
void MyFunc(struct ForThread_struct for_thread, promise<