Skip to content

Fix template deduction for almost_le - #131

Open
tandede wants to merge 1 commit into
leggedrobotics:mainfrom
tandede:fix/almost-le-template-parameters
Open

tandede wants to merge 1 commit into
leggedrobotics:mainfrom
tandede:fix/almost-le-template-parameters

Conversation

@tandede

@tandede tandede commented Aug 25, 2026

Copy link
Copy Markdown

Summary

The two-argument almost_le(x, y) overload declares three template type parameters even though only two appear in its function arguments. T3 can therefore never be deduced, so ordinary calls to this public helper fail at compile time. The neighboring almost_ge(x, y) overload already uses the intended two-parameter form.

This removes the unused T3 from only the default-precision overload. The explicit three-argument overload remains unchanged, so its caller-selected precision behavior is preserved.

Regression coverage

A new test is added to the existing ocs2_core_test_misc target. It exercises strict less-than, equality, a one-ULP approximate comparison in the reverse direction, and a clearly greater value. Keeping the test while reverting the production change makes all four calls fail to compile with couldn't infer template argument 'T3'; with the fix, the test compiles and all four assertions pass.

Validation

  • Built and ran the new GoogleTest: 1 test, 4 assertions passed
  • Apple clang-format 21 dry-run on testNumerics.cpp
  • git diff --check

The local macOS environment does not provide the ROS 1/catkin toolchain needed for the complete project build, so the repository's Ubuntu CI will provide the full integration check.

Fixes #72.

Remove the unused, non-deducible third template parameter from the default-precision overload. Add regression coverage for strict, equal, approximate, and false comparisons in the existing misc test target.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Seem wrong with function almost_ge

1 participant