mirror of
https://github.com/KhronosGroup/Vulkan-Hpp.git
synced 2024-10-14 16:32:17 +00:00
124 lines
3.0 KiB
C++
124 lines
3.0 KiB
C++
template <typename T> void ignore(T const &) VULKAN_HPP_NOEXCEPT {}
|
|
|
|
template <typename T>
|
|
struct ResultValue
|
|
{
|
|
#ifdef VULKAN_HPP_HAS_NOEXCEPT
|
|
ResultValue( Result r, T & v ) VULKAN_HPP_NOEXCEPT(VULKAN_HPP_NOEXCEPT(T(v)))
|
|
#else
|
|
ResultValue( Result r, T & v )
|
|
#endif
|
|
: result( r )
|
|
, value( v )
|
|
{}
|
|
|
|
#ifdef VULKAN_HPP_HAS_NOEXCEPT
|
|
ResultValue( Result r, T && v ) VULKAN_HPP_NOEXCEPT(VULKAN_HPP_NOEXCEPT(T(std::move(v))))
|
|
#else
|
|
ResultValue( Result r, T && v )
|
|
#endif
|
|
: result( r )
|
|
, value( std::move( v ) )
|
|
{}
|
|
|
|
Result result;
|
|
T value;
|
|
|
|
operator std::tuple<Result&, T&>() VULKAN_HPP_NOEXCEPT { return std::tuple<Result&, T&>(result, value); }
|
|
};
|
|
|
|
#if !defined( VULKAN_HPP_NO_SMART_HANDLE )
|
|
template <typename Type, typename Dispatch>
|
|
struct ResultValue<UniqueHandle<Type, Dispatch>>
|
|
{
|
|
#ifdef VULKAN_HPP_HAS_NOEXCEPT
|
|
ResultValue(Result r, UniqueHandle<Type, Dispatch> && v) VULKAN_HPP_NOEXCEPT
|
|
#else
|
|
ResultValue(Result r, UniqueHandle<Type, Dispatch> && v)
|
|
#endif
|
|
: result(r)
|
|
, value(std::move(v))
|
|
{}
|
|
|
|
std::tuple<Result, UniqueHandle<Type, Dispatch>> asTuple()
|
|
{
|
|
return std::make_tuple( result, std::move( value ) );
|
|
}
|
|
|
|
Result result;
|
|
UniqueHandle<Type, Dispatch> value;
|
|
};
|
|
|
|
template <typename Type, typename Dispatch>
|
|
struct ResultValue<std::vector<UniqueHandle<Type, Dispatch>>>
|
|
{
|
|
# ifdef VULKAN_HPP_HAS_NOEXCEPT
|
|
ResultValue( Result r, std::vector<UniqueHandle<Type, Dispatch>> && v ) VULKAN_HPP_NOEXCEPT
|
|
# else
|
|
ResultValue( Result r, std::vector<UniqueHandle<Type, Dispatch>> && v )
|
|
# endif
|
|
: result( r )
|
|
, value( std::move( v ) )
|
|
{}
|
|
|
|
std::tuple<Result, std::vector<UniqueHandle<Type, Dispatch>>> asTuple()
|
|
{
|
|
return std::make_tuple( result, std::move( value ) );
|
|
}
|
|
|
|
Result result;
|
|
std::vector<UniqueHandle<Type, Dispatch>> value;
|
|
};
|
|
#endif
|
|
|
|
template <typename T>
|
|
struct ResultValueType
|
|
{
|
|
#ifdef VULKAN_HPP_NO_EXCEPTIONS
|
|
typedef ResultValue<T> type;
|
|
#else
|
|
typedef T type;
|
|
#endif
|
|
};
|
|
|
|
template <>
|
|
struct ResultValueType<void>
|
|
{
|
|
#ifdef VULKAN_HPP_NO_EXCEPTIONS
|
|
typedef Result type;
|
|
#else
|
|
typedef void type;
|
|
#endif
|
|
};
|
|
|
|
VULKAN_HPP_INLINE typename ResultValueType<void>::type createResultValueType( Result result )
|
|
{
|
|
#ifdef VULKAN_HPP_NO_EXCEPTIONS
|
|
return result;
|
|
#else
|
|
ignore( result );
|
|
#endif
|
|
}
|
|
|
|
template <typename T>
|
|
VULKAN_HPP_INLINE typename ResultValueType<T>::type createResultValueType( Result result, T & data )
|
|
{
|
|
#ifdef VULKAN_HPP_NO_EXCEPTIONS
|
|
return ResultValue<T>( result, data );
|
|
#else
|
|
ignore( result );
|
|
return data;
|
|
#endif
|
|
}
|
|
|
|
template <typename T>
|
|
VULKAN_HPP_INLINE typename ResultValueType<T>::type createResultValueType( Result result, T && data )
|
|
{
|
|
#ifdef VULKAN_HPP_NO_EXCEPTIONS
|
|
return ResultValue<T>( result, std::move( data ) );
|
|
#else
|
|
ignore( result );
|
|
return std::move( data );
|
|
#endif
|
|
}
|