Boost logo

Boost :

From: renej_at_[hidden]
Date: 2003-04-30 13:08:29


>>From: <renej_at_[hidden]>
>
>> > Even if angle is added as a dimension, to an implementation using an
>> > integer vector, it still wouldn't accommodate any other dimensions
>> > added later, without rewriting the library and unit definitions.
>>
>> how about having the basic SI dimensions and a couple of extra
>> "to-be-defined-by-the-developer" dimensions. In that case, full
>> SI "compliance" and for those who want something extra they can have
>> it. I saw one of the discussed unit libraries provided something like
>> a dimension to be defined by the user/developer.
>
> I think I know a way this may be done, now: Default parameters.
>
> There's several ways of specifying a unit; one is to use a typelist,
> such as "typedef mpl::vector_c<1,0,0,0,0,0,0> kg" (Dave Abrahams also
> showed this approach at the recent ACCU conference), or use template
> parameters for the dimensions. In both ways, defaults may be used (it's
> used internally for mpl::vector, anyway). In fact, all could be
> defaulted (like mpl::vector<>), giving in this case a dimensionless
> unit.
>
> Named template parameters could be a possibility, as well, so you could
> do "typedef unit<kg<>, m<>, s<-2> > newton".

that would be nice; don't forget however that the value type should
probably a template parameter also... and yes, in that case template
typedef's would be nice ;-)
for the moment I'm thinking about something like
template <typename T> struct length : unit_type<T, ...> {}
where unit_type<T, ...> has a "typedef unit<...> type;" in it
so I can do: "length<float>::type my_len"

renej
>
>
> Regards,
>
> Terje
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost


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