mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-05-11 05:29:10 +08:00
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,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…
x
Reference in New Issue
Block a user