This question uses the implementation Either<>found here: https://github.com/LoopPerfect/neither . To be clear, I doubt that this is a problem with this particular library, otherwise I would create a problem there.
The following snippet works as expected:
std::future<std::string> f = std::async(std::launch::async, []()
{
return "test";
}
std::cout << f.get() << std::endl;
And the following generates a segmentation error:
std::future<neither::Either<int, std::string>> f = std::async(std::launch::async, []()
{
return neither::Either<int, std::string>(neither::right(std::string("test")));
});
neither::Either<int, std::string> v = f.get(); // Segmentation fault
std::cout << v.right().value << std::endl;
Refund left(-1)works, as neither::Either<int, int>for left()and right(). I know what std::future::getsegfault can generate - you called it twice, and in this case it std::future::validreturns false just before the call get, but it validreturns true.
Am I missing something here?