Skip to content

Unify scalar multiplications and divisions of R3Elements and Multivectors #1727

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

Merged
merged 5 commits into from
Feb 18, 2018

Conversation

pleroy
Copy link
Member

@pleroy pleroy commented Feb 18, 2018

No description provided.

template<typename D>
struct is_quantity<Quantity<D>> : std::true_type, not_constructible {};
template<>
__m128d ToM128D(int x);
Copy link
Member

Choose a reason for hiding this comment

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

Declare two templatized overloads, one for arbitrary types (with an is_arithmetic static_assert) and one for quantities.

Since the Quantity one actually takes a Quantity (and not Wide<Quantity> or something like that when that appears, or at least will have a separate overload for that), there will be no need for SFINAE tricks here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

operator*(Quantity<LDimension> const& left,
template<typename LScalar, typename RScalar, typename Frame, int rank,
typename = std::enable_if_t<is_quantity<LScalar>::value>>
Multivector<Product<LScalar, RScalar>, Frame, rank>
Copy link
Member

Choose a reason for hiding this comment

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

Note that if you want this to work with wide quantities, a Quantity operator*(Wide<Quantity>, Quantity) has to be declared.

This is OK: we can declare the operators, which allows their usage in a decltype, and put a failing dependent static_assert in their definition to prevent them from being used, e.g., https://godbolt.org/g/DbUP24.

It makes things easier to understand and gives us good diagnostics, so this is probably the way to go.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ack.

@eggrobin eggrobin added the LGTM label Feb 18, 2018
@pleroy pleroy merged commit 9e788ff into mockingbirdnest:master Feb 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants