SafeScalar.h
Go to the documentation of this file.
1 
2 // A Scalar that asserts for uninitialized access.
3 template<typename T>
4 class SafeScalar {
5  public:
6  SafeScalar() : initialized_(false) {}
8  *this = other;
9  }
11  val_ = T(other);
12  initialized_ = true;
13  return *this;
14  }
15 
16  SafeScalar(T val) : val_(val), initialized_(true) {}
18  val_ = val;
19  initialized_ = true;
20  }
21 
22  operator T() const {
23  VERIFY(initialized_ && "Uninitialized access.");
24  return val_;
25  }
26 
27  private:
30 };
SafeScalar::val_
T val_
Definition: SafeScalar.h:28
SafeScalar::operator=
SafeScalar & operator=(const SafeScalar &other)
Definition: SafeScalar.h:10
T
Eigen::Triplet< double > T
Definition: Tutorial_sparse_example.cpp:6
SafeScalar::SafeScalar
SafeScalar(const SafeScalar &other)
Definition: SafeScalar.h:7
Eigen::Triplet< double >
SafeScalar
Definition: SafeScalar.h:4
SafeScalar::SafeScalar
SafeScalar(T val)
Definition: SafeScalar.h:16
SafeScalar::operator=
SafeScalar & operator=(T val)
Definition: SafeScalar.h:17
SafeScalar::SafeScalar
SafeScalar()
Definition: SafeScalar.h:6
SafeScalar::initialized_
bool initialized_
Definition: SafeScalar.h:29
pybind_wrapper_test_script.other
other
Definition: pybind_wrapper_test_script.py:42
VERIFY
#define VERIFY(a)
Definition: main.h:380


gtsam
Author(s):
autogenerated on Sun Dec 22 2024 04:13:09