boostorg / boostorg/thread

boost::future handles std::exception differently from std::future on Windows

Open
#325 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
214
Forks
171
PR merge metrics
No merged PRs in 30d

Description

I'm using VC++2019, I use boost::when_all since std::when_all is not available yet. But I find that boost::async will discard std::exception::what() and use 'Unknown exception' or 'std::exception' instead, on the other hand, std::async could handle the message as expected.

```
#include

#define BOOST_THREAD_PROVIDES_FUTURE
#include

#include

int main() {
auto f1 = boost::async([]{ // the program will print 'my exception' if this line uses 'std::async'.
try{
throw std::invalid_argument("my exception");
}
catch (const std::exception& e) {
throw e;
}
});

try {
f1.get();
}
catch (const std::exception& e) {
std::cout << e.what() << std::endl;
}
}

```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.