Added: DynamicVector::assertSize()

This commit is contained in:
Joakim Hove
2015-10-30 15:32:56 +01:00
parent 2cd69fcbda
commit 2ef418bf86

View File

@@ -58,8 +58,7 @@ namespace Opm {
const T& operator[](size_t index) const {
if (index >= m_timeMap->size())
throw std::range_error("Index value is out range.");
assertSize( index );
if (index < m_data.size())
return m_data[index];
@@ -75,8 +74,7 @@ namespace Opm {
T& operator[](size_t index) {
if (index >= m_timeMap->size())
throw std::range_error("Index value is out range.");
assertSize( index );
if (index >= m_data.size())
m_data.resize( index + 1 , m_defaultValue);
@@ -90,6 +88,11 @@ namespace Opm {
private:
void assertSize(size_t index) const {
if (index >= m_timeMap->size())
throw std::range_error("Index value is out range.");
}
std::vector<T> m_data;
TimeMapConstPtr m_timeMap;