检查是否从类型构造函数创建了完整类型

Check if a complete type is created from a type constructor

我想检查一些完整的类型是否是从类型构造函数创建的,例如在 C++ 中我可以这样做

#include <vector>
#include <iostream>

template<class T>
struct is_vector{
    static constexpr bool value = false;
};
template<class A,class B>
struct is_vector<std::vector<A,B>>{
    static constexpr bool value = true;
};
int main(){
    int i;
    std::vector<int> iv;
    std::cout << is_vector<int>::value << std::endl;
    std::cout << is_vector<std::vector<int>>::value << std::endl;
}

现在我想在 D 中做同样的事情

struct ShaderType(T,string s){
  alias Type = T;
  enum string stringType = s;
}
template isShaderType(T){
  enum isShaderType = false;
}
template isShaderType(A,string s, T: ShaderType!(A,s) ){
  enum isShaderType = true;
}

void main(){
  writeln(isShaderType!(ShaderType!(int,"int")));
}

遗憾的是,这打印出错误,我不确定为什么。

隐式模板参数位于 D:

中列表的末尾
template isShaderType(T: ShaderType!(A,s), A, string s){

另请参阅 std.traits.isInstanceOf