Added casting to value type in ValueWithDefault, allows use in 'if' statements, etc. This was needed for the previous check-in of the global debug flags. Also added code comments.

release/4.3a0
Richard Roberts 2011-02-04 00:51:31 +00:00
parent 7cdb9b3564
commit 21f33d337c
1 changed files with 12 additions and 9 deletions

View File

@ -54,15 +54,18 @@ namespace gtsam {
template<typename T, T defaultValue>
struct ValueWithDefault {
T value;
ValueWithDefault() :
value(defaultValue) {
}
ValueWithDefault(const T& _value) :
value(_value) {
}
T& operator*() {
return value;
}
/** Default constructor, initialize to default value supplied in template argument */
ValueWithDefault() : value(defaultValue) {}
/** Initialize to the given value */
ValueWithDefault(const T& _value) : value(_value) {}
/** Operator to access the value */
T& operator*() { return value; }
/** Implicit conversion allows use in if statements for bool type, etc. */
operator T() const { return value; }
};
}