代码中OpenCV图书馆我发现这个:
template<typename _Tp, int cn> class Vec
{
...
}
typedef Vec<int, 2> Vec2i;
typedef Vec<int, 3> Vec3i;
typedef Vec<float, 2> Vec2f;
typedef Vec<float, 3> Vec3f;
我想要一个 float
类型和可变长度 N
的 Vec
。可以这样写吗
using Vecf<N> = Vec<float, N>;
?
最佳答案
是的,你就快到了。 正确的语法是
template<int N>
using Vecf = Vec<float, N>;
关于c++11 - 我可以使用 using 关键字对模板进行部分专门化吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59838078/