ConfigOptionVector::get_at(idx)
Avoid using exceptons for normal work flow. Assert if the vector is empty.
This commit is contained in:
parent
d775c6c14c
commit
2ab86a4895
1 changed files with 3 additions and 5 deletions
|
@ -1,6 +1,7 @@
|
|||
#ifndef slic3r_Config_hpp_
|
||||
#define slic3r_Config_hpp_
|
||||
|
||||
#include <assert.h>
|
||||
#include <map>
|
||||
#include <climits>
|
||||
#include <cstdio>
|
||||
|
@ -73,11 +74,8 @@ class ConfigOptionVector : public ConfigOptionVectorBase
|
|||
};
|
||||
|
||||
T get_at(size_t i) const {
|
||||
try {
|
||||
return this->values.at(i);
|
||||
} catch (const std::out_of_range& oor) {
|
||||
return this->values.front();
|
||||
}
|
||||
assert(! this->values.empty());
|
||||
return (i < this->values.size()) ? this->values[i] : this->values.front();
|
||||
};
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue