我正在寻找 元组 的 std::vector
或 std::array
变体,其中元组元素放置在 非交错进入单独的内存区域,而不是像 std::vector 那样交错。 >
。
这样做的动机是
- 更好地控制对齐,从而提高矢量优化的性能。
- 防止我们在 OpenGL 中连接低级 CPU-GPU 数据传输操作(例如顶点和颜色数组)时解压数据元素。
取消引用时,迭代器应构造并返回一个 boost::tuple
动态。
我知道并非所有 STL 成员函数都能在此容器中得到有效支持。例如,STL data()
容器成员函数必须动态压缩所有单独的数组到一个可变的动态创建的向量容器中并返回它的数据()。
有人已经建造过这样的桌子容器了吗?
I'm looking for a variant of std::vector
or std::array
of tuples, where the tuple elements are placed non-interleaved into separate memory areas instead of interleaved as would be the case for, for example, a std::vector<std::tuple<...>>
.
The motivations for this is
- Better control over alignment and in turn better performance for vector optimizations.
- Prevents us from having to unpack data-elements when interfacing low-level CPU-GPU data-transfer-operations (such as an array of vertices and colors) in OpenGL.
Iterators should construct and return a boost::tuple<>
on-the-fly when dereferenced.
I'm aware that not all STL-member functions could be supported efficiently in this container. For example the STL data()
container member function would have to dynamically zip together all the separate arrays into a mutable dynamically created vector container and return its data().
Has anybody constructed such a table container already?
发布评论
评论(2)
Boost.Iterator 正是您所描述的:
boost::zip_iterator
Boost.Iterator has exactly what you describe:
boost::zip_iterator
创建一个支持迭代和围绕元组<向量、向量、向量>进行迭代和一些其他操作并以这种方式表示数据的瘦包装器怎么样?我不知道有任何标准容器可以提供您需要的接口。
What about creating a thin wrapper that supports iteration and a few other operations around a
tuple<vector, vector, vector>
and representing the data in that way? I'm not aware of any standard container that provides the interface you need.