Skip to content

Commit

Permalink
relax precautions for wrong uses of StatArray
Browse files Browse the repository at this point in the history
  • Loading branch information
rfranke committed Aug 10, 2015
1 parent 19060fd commit ef23054
Showing 1 changed file with 5 additions and 20 deletions.
25 changes: 5 additions & 20 deletions SimulationRuntime/cpp/Include/Core/Math/Array.h
Expand Up @@ -676,13 +676,12 @@ class StatArray : public BaseArray<T>
/**
* Assign static array with internal storage to static array.
* a = b
* Just copy the data pointer if this array has external storage as well.
* @param b any array of type StatArray
*/
StatArray<T, nelems, external>& operator=(const StatArray<T, nelems, false>& b)
{
if (external)
throw std::runtime_error("Invalid assign operation from internal to external storage StatArray!");
if (nelems > 0 && _data == NULL)
throw std::runtime_error("Invalid assign operation from StatArray to uninitialized StatArray!");
else
b.getDataCopy(_data, nelems);
return *this;
Expand Down Expand Up @@ -741,22 +740,15 @@ class StatArray : public BaseArray<T>
*/
virtual T* getData()
{
if (external)
return _data;
else
return _array.c_array();

return _data;
}

/**
* Access to data (read-only)
*/
virtual const T* getData() const
{
if (external)
return _data;
else
return _array.data();
return _data;
}

/**
Expand All @@ -765,14 +757,7 @@ class StatArray : public BaseArray<T>
*/
virtual void getDataCopy(T data[], size_t n) const
{
if(n>0)
{
if (external)
std::copy(_data, _data + n, data);
else
std::copy(_array.begin(), _array.begin() + n, data);

}
std::copy(_data, _data + n, data);
}

/**
Expand Down

0 comments on commit ef23054

Please sign in to comment.