本质上我很好奇我可以使用多少模板: 假设我有两个没有共同成员的结构
struct A{
int k;
char l;
std::string s;
};
struct B{
long h;
float r;
};
我想写一个模板S,应该是这样的
T<A, 5>
/* contains one std::array<int, 5> called k,
one std::array<char, 5> called l
and one std::array<std::string, 5> called s */
T<B, 3>
/* contains one std::array<long, 3> named h
and one std::array<float, 3> called r */
我遇到的主要障碍是我无法真正摆脱组成结构的类型,有什么办法可以克服这个问题吗?
除了基本内容之外,我在使用模板方面没有太多经验,因此请记住这一点并尝试解释