typedef Vec<int, 2> Vec2i; 这个定义是什么意思?
typedef Vec<int, 2> Vec2i; what does this definition mean?
我在大约5年后又回到了c++。我很快复习了一遍。但有一个定义我不知道。
std::vector
为类模板。
typedef Vec<int, 2> Vec2i;
typedef Vec<int, 3> Vec3i;
typedef Vec<int, 4> Vec4i;
typedef Vec<int, 6> Vec6i;
typedef Vec<int, 8> Vec8i;
我不知道这些数字是干什么用的?是指字节数吗?
来自core.hpp
。
/*!
A short numerical vector.
This template class represents short numerical vectors (of 1, 2, 3, 4 ... elements)
on which you can perform basic arithmetical operations, access individual elements using [] operator etc.
The vectors are allocated on stack, as opposite to std::valarray, std::vector, cv::Mat etc.,
which elements are dynamically allocated in the heap.
The template takes 2 parameters:
-# _Tp element type
-# cn the number of elements
In addition to the universal notation like Vec<float, 3>, you can use shorter aliases
for the most popular specialized variants of Vec, e.g. Vec3f ~ Vec<float, 3>.
*/
template<typename _Tp, int cn> class Vec : public Matx<_Tp, cn, 1>
我猜,Vec
是一个表示n维数学向量的类模板,它看起来像:
template <typename T, int N> class Vec { /* ... */ };
数字指定向量中元素的个数,即具有整数分量的2D向量,具有整数分量的3D向量,等等。
但是没有代码就不可能说。
相关文章:
- 在提升multi_index容器中,是否定义了"default index"?
- #定义c-预处理器常量..我做错了什么
- 用C++中的一个变量定义一个常量
- 部分定义/别名模板模板参数
- C++映射:具有自定义类的运算符[]不起作用(总是返回0)
- #为""定义宏;静态";针对不同的上下文
- 如何确保C++函数在定义之前声明(如override关键字)
- 创建一个函数以在输入为负数或零时输出字符串.第一次执行用户定义的函数
- 当类在C++中定义时,有什么方法可以"register"类吗?
- 在命名空间中定义函数还是限定函数
- 此代码是否违反一个定义规则
- 编译C++时未定义的引用
- 不同翻译单元中不可重载的非内联函数定义
- 为什么在定义函数之前先声明它
- 有没有什么方法可以使用一个函数中定义的常量变量,也可以由c++中同一程序中的其他函数使用
- 在类定义之后定义一个私有方法
- 使用用户定义函数的字符串反转
- 用户定义函数中的指针和输入
- vscode g++链路故障:体系结构x86_64的未定义符号
- typedef Vec<int, 2> Vec2i; 这个定义是什么意思?