>From: "Beman Dawes" <[EMAIL PROTECTED]> > At 02:28 PM 4/19/2003, Pavel Vozenilek wrote: > > > b7- ability to distinguish different types of the same dimension (e.g. > >width of image and width of screen) > > Other examples: It should be an error to try to add gallons of gasoline to > gallons of propane. Not to mention trying to add gallons of unleaded > regular gasoline to unleaded premium gasoline. Except that for certain > purposes "hash totals" for example) there must be a way to do the otherwise > illegal operation.
Both of these might be possible to handle externally to a unit/quantity library, by using different underlying types, e.g.: class arithmetic // Provides arithmetic operations, like e.g. "double" class image_type : public arithmetic { ... } class screen_type : public arithmetic { ... } length<image_type> l1; length<screen_type> l2; new_length=l1+l2; // Error You may argue that it should instead be part of the unit, itself, such as: unit<length,image_type> However, this might make it harder to administer any conversions and their products. You may not want to mix leaded and unleaded gasoline for your car, but shouldn't a chemist be allowed to? By keeping the substance used as the underlying type, you may provide any conversion between them. Another thing is that differentiating between what is operated on (not just units, like meter, dollars, etc.) may be beyond what a quatity library should be concerned with. For example, should the following be allowed: volume<H2> hydrogen; volume<O> oxygen // ... volume<H2O> water=hydrogen+oxygen; // Bang? :) Regards, Terje _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost