nholthaus / units

a compile-time, header-only, dimensional analysis and unit conversion library built on c++14 with no dependencies.
http://nholthaus.github.io/units/
MIT License
962 stars 137 forks source link

Missing operations to match a std:: quantity #105

Closed JohelEGP closed 6 years ago

JohelEGP commented 6 years ago

Greetings.

I had attempted to match units::length::meter_t against a concept that checks that a type matches the std::chrono::duration interface of a quantity without dimensional analysis capabilities. This led me to find out that the library quantity types are missing the unary plus and pre and post increment and decrement operators.

I didn't find any reason for their lack, so I'd like to suggest their addition for the benefit of interface consistency (specially in generic interfaces) and convenience (we prefer ++x to x+=1, don't we?)

Thanks for reading.

nholthaus commented 6 years ago

thanks, probably just an oversight. Should be in the next minor release.

nholthaus commented 6 years ago

also, if you don't mind sharing your concept check, I could add it to the unit testing.

JohelEGP commented 6 years ago

I used these concepts. With a proper extension to support the std::chrono::duration-like common_type semantics and with the changes that closed this issue, the types of this library pass the tests.

nholthaus commented 6 years ago

Thank you for sharing! You should have the operators you need in 2.3.1, and I'm going to add common_type support to 3.0 because of this.

Your code looks really good. If you come up with anything you think belongs in the mainline, don't hesitate to make a PR!

JohelEGP commented 6 years ago

Thanks to you too!