Cloned library Eigen-3.4.0 with extra build files for internal package management.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

30 lines
605 B

// A Scalar that asserts for uninitialized access.
template<typename T>
class SafeScalar {
public:
SafeScalar() : initialized_(false) {}
SafeScalar(const SafeScalar& other) {
*this = other;
}
SafeScalar& operator=(const SafeScalar& other) {
val_ = T(other);
initialized_ = true;
return *this;
}
SafeScalar(T val) : val_(val), initialized_(true) {}
SafeScalar& operator=(T val) {
val_ = val;
initialized_ = true;
}
operator T() const {
VERIFY(initialized_ && "Uninitialized access.");
return val_;
}
private:
T val_;
bool initialized_;
};