Boost logo

Boost :

From: Peder Holt (peder.holt_at_[hidden])
Date: 2007-01-16 02:14:39


2007/1/16, Matthias Schabel <boost_at_[hidden]>:
> > Not impossible, just add another layer of indirection:
> >
> > template<typename T1,typename T2>
> > class quantity : public quantity_impl<
> > typename mpl::if_<
> > is_unit<T1>,T2,T1
> >> ::type,
> > typename mpl::if_<
> > is_unit<T1>,T1,T2
> >> ::type
> >> {};
>
> This is intriguing, but I'm not sure how one would enable a default
> template argument on just the value_type... Any ideas?

template<typename T1,typename T2=double>
struct quantity : public ...
{
};

Using quantity, you would then get a compilation error if you tried
using quantity<double>, because then both T1 and T2 would evaluate to
double...

Alternatively:
template<typename T1,typename T2=double>
struct quantity {
//Implementation of quantity here, T1 is the value type, T2 is the unit type.
};

template<typename T1>
struct quantity<T1,double> : public quantity<double,T1> {};

Peder

>
> Matthias
>
>
> _______________________________________________
> 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