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_
|
#ifndef slic3r_Config_hpp_
|
||||||
#define slic3r_Config_hpp_
|
#define slic3r_Config_hpp_
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <climits>
|
#include <climits>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
@ -73,11 +74,8 @@ class ConfigOptionVector : public ConfigOptionVectorBase
|
||||||
};
|
};
|
||||||
|
|
||||||
T get_at(size_t i) const {
|
T get_at(size_t i) const {
|
||||||
try {
|
assert(! this->values.empty());
|
||||||
return this->values.at(i);
|
return (i < this->values.size()) ? this->values[i] : this->values.front();
|
||||||
} catch (const std::out_of_range& oor) {
|
|
||||||
return this->values.front();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue