想实现类似下面的功能:
template<int D>
struct A:vector<A<D-1>>;
using A<0> = int;
即实现一个类似 D 维矩阵的东西。
但是好像没法把 A<0> 特化成 int。不知如何解决?
想实现类似下面的功能:
template<int D>
struct A:vector<A<D-1>>;
using A<0> = int;
即实现一个类似 D 维矩阵的东西。
但是好像没法把 A<0> 特化成 int。不知如何解决?
已解决,可以这么实现:
template <int D>
struct _kdpoly : vector<_kdpoly<D-1>> {};
template <>
struct _kdpoly<1> : vector<int> {};
template <int D>
struct _kdpoly_type {
using type = _kdpoly<D>;
};
template <>
struct _kdpoly_type<0> {
using type = int;
};
template <int D>
using kdpoly = typename _kdpoly_type<D>::type;