// // Created by Brady Bodily on 11/17/19. // #ifndef HW7_8_WEIGHT_HPP #define HW7_8_WEIGHT_HPP #include namespace usu { template class weight { private: T2 valCount; public: using ratio = T; weight() : valCount(0){}; weight(T2 count) : valCount(count){}; T2 count() { return valCount; }; }; template T weight_cast(T2 input) { return T(static_cast((T::ratio::den * T2::ratio::num) * input.count()) / (T::ratio::num * T2::ratio::den)); } template T operator*(double scalar, T weight) { auto count = weight.count(); auto newCount = (scalar * count); T newweight(newCount); return newweight; } template T operator*(T weight, double scalar) { return scalar * weight; } template T operator+(T l, T2 r) { T returnWeight(l.count() + r.count()); return returnWeight; } template T operator-(T l, T2 r) { T returnWeight(l.count() - r.count()); return returnWeight; } //america using ounce = weight, double>; using pound = weight, double>; using ton = weight, double>; //metrics using microgram = weight>; using gram = weight>; using kilogram = weight>; } #endif // HW7_8_WEIGHT_HPP