We can currently not deal with non-Natural bases. This can be an issue when using sqrt or other mathematical operations.
Example:
Area a = 25_m2;
Length l = sqrt(a);
=> error: conversion from ‘double’ to non-scalar type ‘SciQ::Length {aka SciQ::Quantity<1, 0, 0, 0, 0, 0, 0>}’ requested
Manual workaround
There is a manual workaround by keeping track of the units ourselves:
Area a = 25_m2;
Length l = sqrt(a)*meter;
=> length is 5 m
Downside is of course that we need to keep track of what happens to the units.
Potential solution
A potential solution seams to be to use the std::ratio to represent the base instead of just int. It would look like this:
template<class L, class M, class T, class EC, class TT, class AS, class LI>
class Quantity {
// Everything more or less as before
};
using Length = Quantity< ratio<1,1>, ratio<0,1>, ratio<0,1>, ratio<0,1>, ratio<0,1>, ratio<0,1>, ratio<0,1> >;
The main things that has to be changed will be the operator *,/,+,-,==,!=,>=,<=, << overloads to correctly manipulate these ratios.
We can currently not deal with non-Natural bases. This can be an issue when using sqrt or other mathematical operations.
Example:
Manual workaround
There is a manual workaround by keeping track of the units ourselves:
Downside is of course that we need to keep track of what happens to the units.
Potential solution
A potential solution seams to be to use the std::ratio to represent the base instead of just int. It would look like this:
The main things that has to be changed will be the operator *,/,+,-,==,!=,>=,<=, << overloads to correctly manipulate these ratios.
I suggest branching this off