I need a class to have an Eigen::Ref variable as a static member which would be initialized through an init static method. Something like this:
clas
In your case you should very likely better use a VectorXd
, otherwise you would have to make sure that the VectorXd
you passed to init is never destroyed.
The only reason to use a Ref
here would be to allow initializing data
with, e.g., a column of a Matrix
without any copy.
Finally, if you want to reassign a Ref
to reference another buffer, then use a placement new to re-call the constructor of Ref. Don't forget to call the destructor first.