2 ms·
Yup. So I explicitly deleted operators for °C, so things like 5_degC + 10_degC won't compile.
by majorexception 3y ago
Yup. So I explicitly deleted operators for °C, so things like 5_degC + 10_degC won't compile.
- pests 3y agoBut cant you just implement operator+(celcius, celcius) that will do the conversion to kelvin and back, since you know for certain the conversion math?
- majorexception 3y agoI did that, but then adding 0_degC + 0_degC gave 273.15_degC. I think that would be surprising to many people. In reality I don't remember ever having to deal with physics formulas that used °C instead of Kelvins, so the only time I need to use °C is when presenting the temperature in the UI: temperature.in<si::Celsius>()
- pests 3y agoDuh. I was thinking too much on the syntax side and not thinking about the physical world; which is ironic considering the discussion topic.
- phanimahesh 3y agoAdding temperatures is not done usually. Mixing substances adds thermal energy. There's no reason I can hink of why allowing plus operator on temperatures is a good idea. You can add temperature differentials, but it is plain addition so long as units are in agreement. And 0C differential is 0F differential, no offsets in conversions.