Vulkan-Hpp/snippets/resultChecks.hpp

28 lines
1016 B
C++
Raw Permalink Normal View History

VULKAN_HPP_INLINE void resultCheck( Result result, char const * message )
{
#ifdef VULKAN_HPP_NO_EXCEPTIONS
ignore( result ); // just in case VULKAN_HPP_ASSERT_ON_RESULT is empty
ignore( message );
VULKAN_HPP_ASSERT_ON_RESULT( result == Result::eSuccess );
#else
if ( result != Result::eSuccess )
{
throwResultException( result, message );
}
#endif
}
VULKAN_HPP_INLINE void resultCheck( Result result, char const * message, std::initializer_list<Result> successCodes )
{
#ifdef VULKAN_HPP_NO_EXCEPTIONS
ignore( result ); // just in case VULKAN_HPP_ASSERT_ON_RESULT is empty
ignore( message );
ignore( successCodes ); // just in case VULKAN_HPP_ASSERT_ON_RESULT is empty
VULKAN_HPP_ASSERT_ON_RESULT( std::find( successCodes.begin(), successCodes.end(), result ) != successCodes.end() );
#else
if ( std::find( successCodes.begin(), successCodes.end(), result ) == successCodes.end() )
{
throwResultException( result, message );
}
#endif
}