Comments (5)
I'm not sure it can be done. I could be wrong though, and if so would welcome a patch.
There is some nuance to working with arithmetic operators in the units library. Not sure how deeply you've delved into the code, but unit_t
types are a CRTP construct inheriting from a so-called non-linear scale
. The idea behind the NLS is that different arithmetic could be supported for different scales. So far, two are supported:
- linear scale: implements standard arithmetic
- decibel scale: implements log arithmetic for dB units
You could envision other logarithmic or exponential scales. I even did some testing that showed that datum-shifted scales like the Richter Scale were possible.
My recollection is a bit hazy, but I think when it came to compound assignment, I got foiled by the fact that base-class assignment isn't the same as inherited class assignment, or something like that. Or maybe it was just an oversight.
Additionally, you have to be careful with the enable_if
template parameters (mostly not to break implicit conversion of dimensionless units back and forth to the underlying type), and the different RHS types that need to be supported. Copying an existing operator would be a good starting point. I'd encourage you to give it a try, at minimum you'll learn something, and then you could share that knowledge back with us :)
from units.
note to self: maybe possible as non-member?
from units.
I take back what I said, I think this is an easy addition.
from units.
Cool, thanks! I had written my own implementation but I'll pull yours down now.
from units.
If you end up making any more improvements, feel free to share them back :)
from units.
Related Issues (20)
- 2.3.2 Fails to compile HOT 2
- Conan package out of date HOT 2
- Undefined references to .name() and .abbreviation() HOT 1
- Incorrect enable_if condition for operator+ HOT 1
- Request for branch and pull request permissions HOT 5
- percent_t FROM double and TO double are different HOT 9
- 2.3.3 does not compile
- Add a way to specify units when "downcasting" to numeric type HOT 2
- Support the MSFS SDK HOT 2
- Empty base class optimization for MSVC
- Does not compile with GCC 12 HOT 1
- raw() and value() is error prone HOT 4
- [Bug] i386 (32-bit) fails to compile
- Shouldn't the naming of units::torque::foot_pound be changed
- v2 -> v3 porting HOT 2
- Need help implementing resistance as a new custom unit. HOT 2
- unit conversion emits a surprisingly high amount of instructions
- Compilation under MINGW
- Math functions not compatible with percent HOT 1
- Status of the project HOT 14
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from units.