mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-10 08:03:05 -06:00
Improved FixedArray
This commit is contained in:
parent
819a2ab93e
commit
776ed7755e
@ -44,7 +44,7 @@ RigCell::RigCell() :
|
||||
m_cellIndex(cvf::UNDEFINED_SIZE_T),
|
||||
m_coarseningBoxIndex(cvf::UNDEFINED_SIZE_T)
|
||||
{
|
||||
memcpy(m_cornerIndices.m_array, undefinedCornersArray, 8*sizeof(size_t));
|
||||
memcpy(m_cornerIndices.data(), undefinedCornersArray, 8*sizeof(size_t));
|
||||
|
||||
m_cellFaceFaults[0] = false;
|
||||
m_cellFaceFaults[1] = false;
|
||||
|
@ -47,15 +47,23 @@ namespace caf
|
||||
template < typename T, size_t size >
|
||||
class FixedArray
|
||||
{
|
||||
public:
|
||||
T m_array[size];
|
||||
template<typename IndexType> T& operator[](const IndexType& index) { CVF_TIGHT_ASSERT(static_cast<size_t>(index) < size); return m_array[index]; }
|
||||
template<typename IndexType> const T& operator[](const IndexType& index) const { CVF_TIGHT_ASSERT(static_cast<size_t>(index) < size); return m_array[index]; }
|
||||
public:
|
||||
|
||||
const T* data() const { return m_array; }
|
||||
T* data() { return m_array; }
|
||||
|
||||
FixedArray<T, size>& operator=(const T* ptr) { for (size_t i = 0; i < size ; ++i) m_array[i] = ptr[i]; return *this;}
|
||||
|
||||
template<typename IndexType> T& operator[](const IndexType& index) { CVF_TIGHT_ASSERT(static_cast<size_t>(index) < size); return m_array[index]; }
|
||||
template<typename IndexType> const T& operator[](const IndexType& index) const { CVF_TIGHT_ASSERT(static_cast<size_t>(index) < size); return m_array[index]; }
|
||||
};
|
||||
|
||||
typedef FixedArray<int, 3> IntArray3;
|
||||
typedef FixedArray<int, 4> IntArray4;
|
||||
typedef FixedArray<int, 8> IntArray8;
|
||||
typedef FixedArray<unsigned int, 4> UintArray4;
|
||||
typedef FixedArray<unsigned int, 8> UintArray8;
|
||||
typedef FixedArray<size_t, 3> SizeTArray3;
|
||||
typedef FixedArray<size_t, 4> SizeTArray4;
|
||||
typedef FixedArray<size_t, 6> SizeTArray6;
|
||||
|
Loading…
Reference in New Issue
Block a user