Skip to content

Commit

Permalink
Make Pose3<T>::error() static instead of a friend.
Browse files Browse the repository at this point in the history
The ADL-based friend lookup is helpful for operators but confusing
and unnecessary for regular functions.
  • Loading branch information
Patrick Mihelich committed Dec 17, 2024
1 parent ef19cee commit 25fffee
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cpp/sophus/lie/pose3.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class Pose3 {
tangent_in_b_);
}

friend Expected<Tangent> error(
static Expected<Tangent> error(
Pose3 const& lhs_a_from_b, Pose3 const& rhs_a_from_b) {
return (lhs_a_from_b.inverse() * rhs_a_from_b)
.and_then([](Expected<Pose3> const& pose) -> Expected<Tangent> {
Expand Down
5 changes: 1 addition & 4 deletions py/pybind/lie_pybind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,11 +332,8 @@ void bind_lie(py::module_& m) {
.def_static(
"error",
[](sophus::Pose3F64 const& lhs_a_from_b, sophus::Pose3F64 const& rhs_a_from_b) {
// Note: error is a friend function defined inline in Pose3<T>, so it can only
// be found via ADL. That requires unqualified name lookup; sophus::error
// would not be found.
farm_ng::Expected<sophus::Pose3F64::Tangent> err =
error(lhs_a_from_b, rhs_a_from_b);
sophus::Pose3F64::error(lhs_a_from_b, rhs_a_from_b);
if (err) {
return err->array();
}
Expand Down

0 comments on commit 25fffee

Please sign in to comment.