c++ - 在 C++ 中对 typedef struct 数组使用什么

标签 c++

我一直在使用另一段源代码在我的应用程序中实现可视化调试器。当我偶然发现他们使用这个时,我遇到了一个问题..

struct DebugVertex
{
    gkVector3 v;
    unsigned int color;
};


typedef utArray<DebugVertex> Buffer;

我找到了他们为 utArray 使用的免费库,但是我喜欢尽可能坚持使用包含的库(看起来他们使用外部库只是因为原因)。这就是 utArray 的定义......

template <typename T>
class utArray
{
public:
    typedef T           *Pointer;
    typedef const T     *ConstPointer;

    typedef T            ValueType;
    typedef const T      ConstValueType;

    typedef T           &ReferenceType;
    typedef const T     &ConstReferenceType;

    typedef utArrayIterator<utArray<T> >       Iterator;
    typedef const utArrayIterator<utArray<T> > ConstIterator;

public:
    utArray() : m_size(0), m_capacity(0), m_data(0), m_cache(0)  {}

    utArray(const utArray<T>& o)
        : m_size(o.size()), m_capacity(0), m_data(0), m_cache(0)
    {
        reserve(m_size);
        copy(m_data, o.m_data, m_size);
    }

我可以使用类似的东西吗?我没有基于结构数组定义类型的经验,因此我们将不胜感激。

最佳答案

在我看来它很像一个 std::vector ... ( #include <vector> )

关于c++ - 在 C++ 中对 typedef struct 数组使用什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3773385/

相关文章:

c++ - 不识别键盘输入

c++ - 将内存文件添加到 clang CompilerInstance

c++ - 为什么 `std::istream_iterator` 没有右值构造函数?

c++ 实现友元/内联函数

c++ - Eclipse 中 C++ 重构支持的状态如何?

C++引用变量声明语法推理

c++ - 如何使用opencv c++的聚类根据面积和高度对连通分量进行分类

c++ - 类设计建议 - C++

c++ - 将结构与消息一起发送,累积消息并重新发送给 Veins 中的邻居

c++ - 未定义对头文件函数的引用