Convert back from make_status_code_ptr
DaanDeMeyer opened this issue · comments
Is it possible to convert a system_code
made with make_status_code_ptr
back to its original non-type erased status_code?
Use case is bubbling up an error as a system_code
which doesn't fit in an intptr_t
but then converting it back to the actual non-erased status_code to get information out of its value_type.
It should "just work". Can you give me a repro where it does not just work?
I'm sure it works and I'm just overlooking something. I was just looking at the code for indirecting_domain
and saw it uses a custom domain id so wouldn't that break all checks on domain id when wanting to cast back since you can't check what kind of error code you have?
if (erased.domain() == specific::domain()) {
}
Wouldn't this fail when erased
is a status code of domain specific
that's constructed with make_status_code_ptr
since it's domain is different?
Ah, I see what you mean. What we need here is a specialisation for std::get()
and std::get_if()
which allows the extraction of the type erased original. Perhaps also a member function for extracting the original's domain id as well. Thanks for the idea, good catch.
Done