razeh
razeh

Reputation: 2765

std::move data out of Eigen::Matrix

Is there a way to do an std::move, or the moral equivalent, of the data inside a dynamically sized Eigen::Matrix? I want to move the data out for use in my own API.

Upvotes: 0

Views: 736

Answers (1)

chtz
chtz

Reputation: 18807

Since you did not clarify what you actually want to do, a more generic answer:

No, there is no way to move the data out of an Eigen::Matrix without accessing internals of Eigen (e.g., if you inherit from Eigen::Matrix you have access to all internal data). I will not elaborate on how to do this, since this could break anytime if the internals of Eigen change.

There are generally two "correct" ways (or a combination of those) to interact with different APIs:

  1. Use Eigen objects for data storage and get read-write access to the internal data using the .data() function.
  2. Use your own API for data storage, and use Eigen::Map to access that data from Eigen's side: https://eigen.tuxfamily.org/dox/group__TutorialMapClass.html

Upvotes: 2

Related Questions