The Eigen3 documentation warns against passing Eigen objects by value, but they only refer to objects being used as function arguments.
Suppose I'm using Eigen 3.4.0 and C++20. If I have a struct
with an Eigen member, does this mean I can't std::move
a pass-by-value in the constructor? Do I need to pass-by-reference and copy the object? Or is this handled somehow by modern move-semantics?
If I can't std::move
Eigen objects in a constructor, does this mean I should explicitly delete the move-constructors from my struct?
For example,
#include <utility>
#include <Eigen/Core>
struct Node {
Eigen::Vector3d position;
double temperature;
// is this constructor safe to use?
Node(Eigen::Vector3d position_, const double temperature_)
: position(std::move(position_)), temperature(temperature_) {}
// or must it be this?
Node(const Eigen::Vector3d& position_, const double temperature_)
: position(position_), temperature(temperature_) {}
// also, should move-constructors be explicitly deleted?
Node(Node&&) = delete;
Node& operator=(Node&&) = delete;
};