Created
April 8, 2016 01:16
-
-
Save Porges/fa50b5c7584b23828e6a212ba8fdb711 to your computer and use it in GitHub Desktop.
successful_hresult
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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