Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add raw() to point and tripoint. #77837

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

CLIDragon
Copy link
Contributor

Summary

None

Purpose of change

This makes it possible to reason about a generic point object that may be a raw point / tripoint or a typed coordinate. This came up in #75961.

In particular, the change would allow expressing the following line:

const Point next = Point{ ( center + p).raw() };

for which there is currently no way to express. This would also allow getting rid of some overloads in favour of generic implementations (e.g. the closest_point_first overloads in coordinates.h)

Describe the solution

Add raw() methods to point and tripoint that create a new object with the same details.

Describe alternatives you've considered

Adding raw at callsites. This means that points have to be converted to the correct type system at the callsite, which is less than ideal.

Using template<typename Point, coords::origin Origin, coords::scale Scale>. However, I don't think this works with raw points, so they would have to be converted.

Testing

Additional context

This makes it possible to reason about a generic point object that may
be a raw point / tripoint or a typed coordinate.
src/point.h Outdated Show resolved Hide resolved
@github-actions github-actions bot added the [C++] Changes (can be) made in C++. Previously named `Code` label Nov 14, 2024
@github-actions github-actions bot added json-styled JSON lint passed, label assigned by github actions astyled astyled PR, label is assigned by github actions and removed json-styled JSON lint passed, label assigned by github actions labels Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions [C++] Changes (can be) made in C++. Previously named `Code` json-styled JSON lint passed, label assigned by github actions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants