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

Remove operator++ and operator-- for floating point representations? #18

Closed
jansende opened this issue Sep 30, 2019 · 4 comments
Closed
Assignees
Labels
question Further information is requested
Milestone

Comments

@jansende
Copy link
Contributor

Should operator++ and operator-- be disabled for floating point representations? Also, as for operator%, how should these operations be disabled?

@mpusz
Copy link
Owner

mpusz commented Oct 1, 2019

I agree that ++ and -- do not have much sense for floating-point representations but those operations are defined for a floating-point number. So if the following works:

double length = 3;
++length; 

I think it should work as well for a safe type:

quantity<metre, double> length(3);
++length;   // should also work

Also it has benefits from a generic point of view:

Quantity foo(Quantity auto q)
{
  return ++q;
}

The user should not be forced to check what is the Rep there.

Basically, if we do not provide those operators users will have to use += 1 in a generic code which basically is the same wrong for a floating-point number and we probably do not want to ban it too ;-)

@mpusz mpusz added the question Further information is requested label Oct 1, 2019
@jansende
Copy link
Contributor Author

jansende commented Oct 2, 2019

I think generic programming is a fine argument for why these operator should be left.
Maybe we should add this to the paper in a section titled: Supported Operations and Representations?

@mpusz
Copy link
Owner

mpusz commented Oct 3, 2019

Sure, this a good idea. Do you volunteer to write one? ;-)

@mpusz mpusz self-assigned this Nov 8, 2019
@mpusz mpusz added this to the v0.4.0 milestone Nov 8, 2019
@mpusz
Copy link
Owner

mpusz commented Nov 9, 2019

More on this subject in #29

@mpusz mpusz closed this as completed in 04cbeb8 Nov 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants