symforce-org / symforce

Fast symbolic computation, code generation, and nonlinear optimization for robotics
https://symforce.org
Apache License 2.0
1.41k stars 145 forks source link

Mark Eigen results of functions like `Pose3::Position()` as const #312

Closed aaron-skydio closed 1 year ago

aaron-skydio commented 1 year ago

Should make it impossible to attempt something like

auto p = sym::Pose3();
p.Position().x() = 5;

Currently this is a noop (because Position() returns a temporary). We want the geo types to remain immutable (for conceptual simplicity), making the return value const makes this a compile error.

It's possible there are more things which should have const return values (all generated functions that return eigen types?), and it may or may not be easier to just do all of those.