Skip to content

Instantly share code, notes, and snippets.

@Porges
Created April 8, 2016 01:16
Show Gist options
  • Save Porges/fa50b5c7584b23828e6a212ba8fdb711 to your computer and use it in GitHub Desktop.
Save Porges/fa50b5c7584b23828e6a212ba8fdb711 to your computer and use it in GitHub Desktop.
successful_hresult
struct successful_hresult
{
HRESULT hr_;
HRESULT throw_if_failed(HRESULT hr)
{
if (FAILED(hr))
{
throw ...;
}
return hr;
}
public:
successful_hr(HRESULT hr)
: hr_{throw_if_failed(hr)}
{}
operator HRESULT() const noexcept
{
return hr_;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment