traits: add is_native/is_wrapper queries

This commit is contained in:
Danny Robson 2017-09-08 17:56:22 +10:00
parent f7c54e0b9d
commit 6e1ffd4d0e

View File

@ -118,6 +118,52 @@ namespace cruft::vk {
using native_t = typename native_traits<T>::type; using native_t = typename native_traits<T>::type;
///////////////////////////////////////////////////////////////////////////
/// defines whether a type is a native vulkan object.
///
/// note that this only returns true for handle types, not parameter types.
/// eg, VkDevice will return true, but VkDeviceCreateInfo will not.
template <typename>
struct is_native : public std::false_type { };
//-------------------------------------------------------------------------
#define DEFINE_IS_HANDLE(KLASS) \
template <> \
struct is_native<native_t<KLASS>> : \
public std::true_type \
{ };
VK_TYPE_MAP (DEFINE_IS_HANDLE)
#undef DEFINE_IS_HANDLE
//-------------------------------------------------------------------------
template <typename T>
static constexpr auto is_native_v = is_native<T>::value;
///////////////////////////////////////////////////////////////////////////
template <typename>
struct is_wrapper : public std::false_type { };
//-------------------------------------------------------------------------
#define IS_WRAPPER(KLASS) \
template <> \
struct is_wrapper<KLASS> : \
public std::true_type \
{ };
VK_TYPE_MAP(IS_WRAPPER)
#undef IS_WRAPPER
//-------------------------------------------------------------------------
template <typename T>
static constexpr auto is_wrapper_v = is_wrapper<T>::value;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
/// describes the native type that owns a given native type, and hence /// describes the native type that owns a given native type, and hence
/// forms part of the create/destroy process. /// forms part of the create/destroy process.