Boost logo

Boost :

From: Dean Foster (foster_at_[hidden])
Date: 2001-09-15 14:38:27


> From: eford_at_[hidden]
>
> So I'd say something like
> typedef enum { sugar = 100, flour = 101 } ingredients;
> typedef unit_unconvertible<teaspoon, ingredients::sugar>
> teaspoon_of_sugar;
> typedef unit_unconvertible<tablespoon, ingredients::sugar>
> tablespoon_of_sugar;
> typedef unit_unconvertible<cup, ingredients::flour> cup_of_flour;
>
> Then conversions between different "of sugar" units would be
> automatic, but conversions between any unit of sugar and any unit of
> flour would generate compile time errors.
>

I think you hit the nail on the head here. There are two very
different concepts: how you measure something, and what is being
measured. Often times what is being measured is the more important
detail. I want to be able to have a signature of a function that
identifies which arguments are sugar and which are flour. So this
double templating might sort out this distinction.

dean

=============================================================================
Dean Foster dean_at_[hidden]
Statistics, Wharton, U. Penn 215 898 8233
Philadelphia PA 19104-6302 http://diskworld.wharton.upenn.edu


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk