我正在尝试编写一个类型特征以检测给定类型K是否可以调用static_cast此类型K(或引用K)的变量uint32_t。
这就是我要达到的目标,但似乎无法使其正常工作。
template <typename K, typename Whatever = void> struct ConvertibleToUint32 {
static constexpr bool value = false;
};
template <typename K>
struct ConvertibleToUint32<K, decltype(static_cast<uint32_t>(std::declval<K>()))> {
static constexpr bool value = true;
};
Run Code Online (Sandbox Code Playgroud)
我也尝试过使用std :: is_convertible,但似乎在这里不起作用。
这是运行的粘贴-https: //wandbox.org/permlink/iuP99PNAVIYhh208
专业化似乎没有受到打击。
这是完整的测试程序-
#include <iostream>
#include <stdint.h>
template <typename K, typename Whatever = void> struct ConvertibleToUint32 {
static constexpr bool value = false;
};
template <typename K>
struct ConvertibleToUint32<K, decltype(static_cast<uint32_t>(std::declval<K>()))> {
static constexpr …Run Code Online (Sandbox Code Playgroud) D3D11_INPUT_ELEMENT_DESC在 Direct3D 中,当我们使用和 调用指定顶点着色器的输入时IASetVertexBuffers,我们必须指定“输入槽”。这些输入槽到底是什么?OpenGL 等效项是什么?这些输入槽似乎与layout(location = K)GLSL 中指定的“位置”和glVertexAttribPointer.