traits: add structure_type trait for native types
This commit is contained in:
parent
4848692016
commit
d88ecaf613
27
traits.hpp
27
traits.hpp
@ -12,7 +12,7 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
* Copyright:
|
||||
* 2016, Danny Robson <danny@nerdcruft.net>
|
||||
* 2016-2017, Danny Robson <danny@nerdcruft.net>
|
||||
*/
|
||||
|
||||
#ifndef CRUFT_VK_TRAITS_HPP
|
||||
@ -21,7 +21,32 @@
|
||||
#include "./fwd.hpp"
|
||||
#include "./vk.hpp"
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
|
||||
namespace cruft::vk {
|
||||
/// describes the corresponding value for sType in native structures
|
||||
template <typename T>
|
||||
struct structure_type {};
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
#define DEFINE_STRUCTURE_TYPE(KLASS,VALUE) \
|
||||
template <> \
|
||||
struct structure_type<KLASS> : \
|
||||
public std::integral_constant<VkStructureType, VALUE> \
|
||||
{ }
|
||||
|
||||
DEFINE_STRUCTURE_TYPE (VkInstanceCreateInfo, VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO);
|
||||
|
||||
#undef DEFINE_STRUCTURE_TYPE
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
constexpr auto structure_type_v = structure_type<T>::value;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename T> struct id_traits { };
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user