Boost logo

Boost :

From: Matthias Schabel (boost_at_[hidden])
Date: 2007-02-19 16:45:30


Steven,

> template<class DimensionMap, class Tag, class System>
> struct
> base_unit_converter<Tag,heterogeneous_system<DimensionMap>,System> :
> base_unit_converter<Tag, typename mpl::at<DimensionMap,
> Tag>::type,System> {
> };

I actually think we can just leave the base_unit_converter template
alone since this deals
with a converting values of one fundamental dimension between two
systems. Then we
can just specialize conversion_helper for homogeneous systems to be
the current
implementation and have the default specialization deal with
heterogeneous systems:

// current implementation for homogeneous systems
template<class S1,
                 class S2,
                 class Dim1,
                 class Y>
class conversion_helper< quantity<unit<homogeneous_system<S1>,Dim1>,Y>,
                                                 quantity<unit<homogeneous_system<S2>,Dim1>,Y> >

// generic implementation for heterogeneous systems
template<class System1,class Dim1,
                 class System2,class Dim2,
                 class Y>
class conversion_helper< quantity<unit<System1,Dim1>,Y>,
                                                 quantity<unit<System2,Dim2>,Y> >

The actual implementation of the latter will probably be the hardest
part...
I've plugged in specializations for homogeneous_system<S> into the
code base and
all examples still work correctly. Once we have a functioning system
that properly
sorts heterogeneous units, we should just have to write
specializations for

struct multiply_typeof_helper< unit< heterogeneous_system<S>,Dim1>,
                                                           unit< heterogeneous_system<S>,Dim2> >

and

struct divide_typeof_helper< unit< heterogeneous_system<S>,Dim1>,
                                                         unit< heterogeneous_system<S>,Dim2> >

unary_plus_typeof_helper, unary_minus_typeof_helper, add_typeof_helper,
subtract_typeof_helper, power_typeof_helper, and root_typeof_helper
all stay
the same as far as I can see...

I'm starting to feel optimistic that we'll be able to get something
very flexible
without adding too much complexity...

Matthias


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