Create a Ptr<> analogon to Ref<>
@chhtz
Submitted by Christoph HertzbergAssigned to Nobody
Link to original bugzilla bug (#912)
Version: 3.3 (current stable)
Description
Ref<> (similar to Map) has the disadvantage that once initialized its reference can't be changed (without a placement-new hack). This is similar to C++ references.
An idea is to add the analogon of a pointer, which can be uninitialized (a NULL pointer) or which can be re-initialized at any time.
For reinitialization operator=(const DenseBase<...>&) can be overloaded.
Alternatively, we could overload operator& for DirectAccess types to return a Ptr object.
Ptr<MatrixXd> A = & M.block(...); // with overloaded operator&
vs
Ptr<MatrixXd> A = M.block(...); // without overloading
But overloading & is very often causing trouble.
For fixed sized Ptr<> objects, initialization by a Scalar* could be considered:
Ptr<Matrix3d> B = data;
To access the referenced data, operator* and operator-> can be overloaded. Furthermore, operator! and operator bool can be overloaded to check if the pointer is NULL or not.