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

[wpiutil] Add rotated_span #7111

Merged
merged 3 commits into from
Oct 11, 2024
Merged

Conversation

PeterJohnson
Copy link
Member

@PeterJohnson PeterJohnson commented Sep 21, 2024

TODO:

  • Change offset constructor parameters to int rotation instead
  • Test rotations

wpiutil/src/main/native/include/wpi/rotated_span.h Outdated Show resolved Hide resolved
wpiutil/src/main/native/include/wpi/rotated_span.h Outdated Show resolved Hide resolved
void const_sized_func(wpi::rotated_span<const int, 10>) {}

TEST(CircularSpanTest, Implicit) {
// unsized_func(csarr_values); // error
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit clunky, but if we want to make sure these are invalid, we could define a concept that checks if a call with a parameter is valid (using a requires expression) and then use static asserts:

template <auto Param, auto Func>
concept ValidParamFor = requires {
  Func(Param);
};

static_assert(!ValidParamFor<csarr_values, unsized_func>);

Note that we do need to define the concept, since "If a substitution failure would occur in a requires-expression for every possible template argument, the program is ill-formed, no diagnostic required." (requires expression)

@PeterJohnson PeterJohnson merged commit f65f9ed into wpilibsuite:main Oct 11, 2024
35 checks passed
@PeterJohnson PeterJohnson deleted the rotated-span branch October 11, 2024 06:36
spacey-sooty pushed a commit to spacey-sooty/allwpilib that referenced this pull request Oct 26, 2024
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.

2 participants