Closed vjohansen closed 3 years ago
From that page you mentioned, I copy and pasted the entire snippet into wandbox, and it executes without crash just fine:
https://wandbox.org/permlink/D8Ly4wIKobBAXM8v
I don't see a godbolt link on that page. Can you clarify?
Probably here https://ned14.github.io/outcome/tutorial/essential/before/
Here is the first tutorial topic’s source code loaded into Godbolt: https://godbolt.org/z/p-NAho
At the bottom there a links to both godbolt and wandbox
Please close this issue.
I looked at my code again and the web page. It turns out I copied only the class ConversionErrc_category which caused a temporary error_category to be created in make_error_code.
This is because I did not copy the
THIS_MODULE_API_DECL const detail::ConversionErrc_category& ConversionErrc_category()
{
static detail::ConversionErrc_category c;
return c;
}
Which is a function with the same name as the class
I am trying to follow the documentation and am copy/pasting code to get a minimal example with
outcome::result<int> convert(const std::string& str) noexcept
working.
This causes a crash when retrieving some_result.error().message()
The issue is on the page https://ned14.github.io/outcome/motivation/plug_error_code/
return {static_cast<int>(e), ConversionErrc_category()};
If i follow the godbolt link the code is
Using a global object made my code example work too