Skip to content

Obtaining a & to an error #5

Discussion options

You must be logged in to vote

I have been in a similar situations in one of my own codebases with a larger error object; though I solved this through an extra layer of indirection by creating an error_handle type that contains either a unique_ptr or shared_ptr to the error data. Is something similar to this a possible workaround for the situation you are experiencing?

This result implementation was designed with the idea that error states are meant to be light-weight. A handle like this makes it easy to return error() and not care for the cost of the copy (which for a handle using shared_ptr, would just be a couple pointer copies and an atomic increment).

Would you be open to accept a PR that changes the result of error

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@alexanderlinne
Comment options

@bitwizeshift
Comment options

Answer selected by alexanderlinne
@alexanderlinne
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants