
Ben FrantzDale wrote:
On 3/28/07, Lewis Hyatt <lhyatt@princeton.edu> wrote:
... Also, quantity<> should pass through operator++ and operator-- in addition to the other arithmetic operators.
I strongly disagree. Those operators make no sense for dimensioned quantities; it would be like allowing "12.34 meters + 1".
It is a common idiom that operator++ means "increment by one 'step', in whatever way is appropriate." For instance, boost::progress_timer provides operator++. But no one is confused as to its meaning--it is clear that the increment is perfomed in the natural units of the object (namely, progress ticks) rather than in absolute numbers. In the boost::units case, it makes perfect sense that the increment of a dimensionful quantity is in the appropriate units. For instance: for(quantity<SI::electric_potential> V = 1 * SI::volt; V != 10*SI::volt; ++V) { cout << "voltage is now at " << V << endl; } I think this is perfectly natural, and should compile. Disallowing this will force users of more complex types to create temporary objects in cases where operator++ would render them unnecessary; I think this is too restrictive. -Lewis