$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Steven Watanabe (steven_at_[hidden])
Date: 2007-02-12 18:35:37
AMDG
Matthias Schabel <boost <at> schabel-family.org> writes:
> As Steven pointed out, this is not a detail - how would you write a
> template
> specialization of mpl::times<> that works for an arbitrary mpl::list?
Well, it is possible, but not a good idea.
template<>
struct mpl::times_impl<mpl::list0<>::tag, mpl::list0<>::tag> {
template<class X, class Y>
struct apply {
//...
};
};
>
> > quantity<SI::length> cent(cents);
> > cent = 2 * meters;
> > assert(cent.value() == 200);
>
> I have no idea what this means. Cents == centimeters? If so,
> centimeter is not an SI unit of length. And with no
> value, the first line doesn't give you a quantity anyway...
I see. What Noah is asking for is
template<class Unit, class T>
class quantity {
//...
private:
T val_;
T multiplier;
};
IMO, separating val_ into two factors
is not generally useful.
> > quantity<SI::length> unknown(user_unit);
> > unknown = 5 * meters;
> > quantity<SI::length> m(meters);
> > m = unknown;
> > assert(m.value() == 5);
> >
> > void f_cgs(quantity<CGS::length> l);
> > f_cgs(quantity_cast<CGS>(cent));
> >
> > The syntax is not necessarily what mcs does or would do but the
> > concepts
> > are what is important.
> >
> > It's been argued that this adds unnecessary complexity or would cause
> > inefficiencies. I don't agree.
>
It does add overhead -- about 2x. This may be
fine for many uses, but for some it would
be unacceptable.
In Christ,
Steven Watanabe