Added: DynamicVector::assertSize()
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user