C++ : Potential Issues with Custom Coded Generic Container?
<p>I am unable to use the STL and boost library and I have to write my own container in C++. The following code compiles without error in VC++6.</p>

<p>I have not actually tested the code but is concerned whether this generic container will work with both primitive and non primitive types (like class). Will there be any potential issues with the copy constructor and the assignment operator especially? </p>

<p>Any other suggestions and comments are most welcomed. :)</p>

<pre><code>template &lt;class T&gt;  
class __declspec(dllexport) StdVector{

private:  
 int _pos;  
 int _size;  
 const T *_items;  

public:
 StdVector();
 StdVector(const StdVector &amp;v);
 StdVector(int size);
 virtual ~StdVector();

 void Add(const T &amp;item);
 void SetSize(int size);
 int GetSize();

 const T * Begin();
 const T * End();
 const T * ConstIterator();

 StdVector &amp; operator=(const StdVector &amp;v);
};

template &lt;typename T&gt;
StdVector&lt;T&gt;::StdVector() 
    : _pos(0), _size(0), _items(NULL){
}

template &lt;typename T&gt;
StdVector&lt;T&gt;::StdVector(const StdVector &amp;v) 
    : _pos(0), _size(v.GetSize()), _items(new T[_size]){
    std::copy(v.Begin(), v.End(), Begin());
}

template &lt;typename T&gt;
StdVector&lt;T&gt;::StdVector(int size) 
    : _pos(0), _size(size), _items(new T[_size]){
}

template &lt;typename T&gt;
StdVector&lt;T&gt;::~StdVector(){
    if (_items != NULL)
     delete[] _items;
}

template &lt;typename T&gt;
void StdVector&lt;T&gt;::Add(const T &amp;item){
    if (_pos == _size)
     throw new exception("Already at max size!!!");

    _items[_pos++] = item;
}

template &lt;typename T&gt;
void StdVector&lt;T&gt;::SetSize(int size){
    if (_items != NULL)
     delete[] _items;

    _pos = 0;
    _size = size;
    _items = new T[_size];
}

template &lt;typename T&gt;
int StdVector&lt;T&gt;::GetSize(){
    return _size;
}

template &lt;typename T&gt;
const T * StdVector&lt;T&gt;::Begin(){
    return _items;
}

template &lt;typename T&gt;
const T * StdVector&lt;T&gt;::End(){
    return _items + _pos;
}

template &lt;typename T&gt;
const T * StdVector&lt;T&gt;::ConstIterator(){
    return _items;
}

template &lt;typename T&gt;
StdVector&lt;T&gt; &amp; StdVector&lt;T&gt;::operator=(const StdVector &amp;v){
    if (this != &amp;v){
        delete[] _items;
        std::copy(v.Begin(), v.End(), Begin());
    }

    return *this;
}
</code></pre>
