Eigen::Ref<> as a member variable

前端 未结 1 490
野性不改
野性不改 2021-01-07 07:15

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         


        
相关标签:
1条回答
  • 2021-01-07 07:40

    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.

    0 讨论(0)
提交回复
热议问题