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

point / tripoint / rectangle / box refactoring and enhancements #32242

Merged

Conversation

jbytheway
Copy link
Contributor

@jbytheway jbytheway commented Jul 7, 2019

Summary

SUMMARY: None

Purpose of change

Needed some new features on point and tripoint for another branch I'm working on.

Want it to be easier and clearer to use bounds-checking with rectangles and boxes.

Describe the solution

Some misc changes
  • Add out-streaming operator to point.
  • Add to_string to point and tripoint.
  • Add Catch2 StringMaker specializations for box and rectangle.
  • Add tripoint::xy to fetch the point part of it.
  • Move some implementations to new point.cpp.
  • Tests.
Overhaul of generic_inbounds
  • Rather than having a free function for generic_inbounds, have two member functions on each of rectangle and box to test bounds.
  • Rather than having an optional clearance parameter, have two names for the two common bounds types (inclusive and half-open ranges). Add box::shrink for the one use case that really required clearance.
  • Refactor all uses to this new API.
  • More constexpr.

The main goal here is to make it easier to use these bounds tests in fewer lines of code for common cases. I also think the member function form reads more smoothly in code.

Describe alternatives you've considered

Could have kept the bounds-checking things as free functions.

Additional context

Ultimately in support of #32017, but multiple steps removed.

jbytheway added 2 commits July 7, 2019 20:53
Some convenience member functions for these types.

And some tests.
Rather than having a free function for generic_inbounds, have two member
functions on each of rectangle and box to test bounds.

Rather than having an optional 'clearance' parameter, have two names for
the two common bounds types (inclusive and half-open ranges).

Refactor all uses to this new API.

The main goal here is to make it easier to use these bounds tests in
fewer lines of code for common cases.  I also think the member function
form reads more smoothly in code.
@ifreund ifreund added [C++] Changes (can be) made in C++. Previously named `Code` Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style labels Jul 7, 2019
@kevingranade kevingranade merged commit 3b8996a into CleverRaven:master Jul 8, 2019
@jbytheway jbytheway deleted the generic_inbounds_overhaul branch July 9, 2019 08:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C++] Changes (can be) made in C++. Previously named `Code` Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants