Fixed Symbol problem - related to using std::numeric_limits::max() statically on keys created outside of functions
parent
f45c236585
commit
9e26b32daa
|
@ -703,6 +703,14 @@
|
|||
<useDefaultCommand>true</useDefaultCommand>
|
||||
<runAllBuilders>true</runAllBuilders>
|
||||
</target>
|
||||
<target name="testKey.run" path="build/gtsam/nonlinear" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||
<buildCommand>make</buildCommand>
|
||||
<buildArguments>-j5</buildArguments>
|
||||
<buildTarget>testKey.run</buildTarget>
|
||||
<stopOnError>true</stopOnError>
|
||||
<useDefaultCommand>true</useDefaultCommand>
|
||||
<runAllBuilders>true</runAllBuilders>
|
||||
</target>
|
||||
<target name="schedulingExample.run" path="build/gtsam_unstable/discrete" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||
<buildCommand>make</buildCommand>
|
||||
<buildArguments>-j5</buildArguments>
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
* @author: Richard Roberts
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <gtsam/nonlinear/Symbol.h>
|
||||
|
||||
#include <boost/mpl/char.hpp>
|
||||
|
@ -27,6 +25,7 @@
|
|||
#include <boost/lambda/construct.hpp>
|
||||
#include <boost/lambda/lambda.hpp>
|
||||
|
||||
#include <limits.h>
|
||||
#include <list>
|
||||
#include <iostream>
|
||||
|
||||
|
@ -35,8 +34,7 @@ namespace gtsam {
|
|||
static const size_t keyBits = sizeof(Key) * 8;
|
||||
static const size_t chrBits = sizeof(unsigned char) * 8;
|
||||
static const size_t indexBits = keyBits - chrBits;
|
||||
static const Key chrMask = Key(std::numeric_limits<unsigned char>::max())
|
||||
<< indexBits;
|
||||
static const Key chrMask = Key(UCHAR_MAX) << indexBits; // For some reason, std::numeric_limits<unsigned char>::max() fails
|
||||
static const Key indexMask = ~chrMask;
|
||||
|
||||
Symbol::Symbol(Key key) {
|
||||
|
@ -45,8 +43,11 @@ namespace gtsam {
|
|||
}
|
||||
|
||||
Key Symbol::key() const {
|
||||
if (j_ > indexMask)
|
||||
throw std::invalid_argument("Symbol index is too large");
|
||||
if (j_ > indexMask) {
|
||||
boost::format msg("Symbol index is too large, j=%d, indexMask=%d");
|
||||
msg % j_ % indexMask;
|
||||
throw std::invalid_argument(msg.str());
|
||||
}
|
||||
Key key = (Key(c_) << indexBits) | j_;
|
||||
return key;
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ using namespace boost::assign;
|
|||
using namespace std;
|
||||
using namespace gtsam;
|
||||
|
||||
Key aKey = gtsam::symbol_shorthand::X(4); // FIXME: throws index too large exception in Symbol.key()
|
||||
Key aKey = gtsam::symbol_shorthand::X(4);
|
||||
|
||||
/* ************************************************************************* */
|
||||
TEST(Key, KeySymbolConversion) {
|
||||
|
|
Loading…
Reference in New Issue