关于一些无法编译的代码的一个非常快速的问题。我写了一个围绕 std::vector 的包装器:
template <class T>
class CLArray
{
public:
/// Constructor, destructor.
CLArray( const size_t size );
CLArray( const size_t size, const T value );
~CLArray();
/// Copy constructor and copy assignment operator.
CLArray( const CLArray& rhs );
CLArray& operator=( const CLArray& rhs );
/// Move constructor and move assignment operator.
CLArray( CLArray&& rhs );
CLArray& operator=( CLArray&& rhs );
void swap( CLArray& other )
{
std::swap( data_, other.data_ );
}
typedef typename std::vector<T>::iterator iterator;
typedef typename std::vector<T>::const_iterator const_iterator;
iterator begin()
{
return data_.begin();
}
const_iterator begin() const
{
return data_.begin();
}
iterator end()
{
return data_.end();
}
const_iterator end() const
{
return data_.end();
}
T& operator[]( const size_t index ) throw(CLException);
T operator[]( const size_t index ) const throw(CLException);
T At( const size_t index ) const throw(CLException);
void SetAt( const size_t index, const T& value ) throw(CLException);
void Insert( ubyte* data, const size_t size );
size_t GetSize() const;
const CLArray<T>& GetData() const;
void Clear();
private:
std::vector<T> data_;
};
我想创建一个用于管理二维 CLArray 的类:
template <class T>
class SomeMap
{
public:
SomeMap( const size_t width, const size_t heigth, const T defaultVal = 0 )
: map_( width, CLArray<T>(heigth, defaultVal) )
{
// Allocate enough memory for all objects
}
~SomeMap() {}
private:
CLArray<CLArray<T>> map_;
//std::vector<std::vector<T>> map_;
};
我得到一个错误:no matching function for call to ‘CLArray<Cell*>::CLArray()
声明一个对象时SomeMap<Cell*> map( 748, 480, nullptr );
,我真的不明白为什么......`