gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:36:17 25 4
gpt4 key购买 nike

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

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com