Throw exception rather than assert (which crashes MATLAB)
parent
9d7d563688
commit
9d4ba6acb9
|
@ -44,9 +44,12 @@ namespace gtsam {
|
||||||
void Factor<KEY>::assertInvariants() const {
|
void Factor<KEY>::assertInvariants() const {
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
// Check that keys are all unique
|
// Check that keys are all unique
|
||||||
std::multiset<Key> nonunique(keys_.begin(), keys_.end());
|
std::multiset < Key > nonunique(keys_.begin(), keys_.end());
|
||||||
std::set<Key> unique(keys_.begin(), keys_.end());
|
std::set < Key > unique(keys_.begin(), keys_.end());
|
||||||
assert(nonunique.size() == unique.size() && std::equal(nonunique.begin(), nonunique.end(), unique.begin()));
|
bool correct = (nonunique.size() != unique.size())
|
||||||
|
&& std::equal(nonunique.begin(), nonunique.end(), unique.begin());
|
||||||
|
if (!correct)
|
||||||
|
throw std::logic_error("Factor::assertInvariants: detected inconsistency");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue