Boost logo

Boost :

From: Reece Dunn (msclrhd_at_[hidden])
Date: 2004-01-08 11:55:33


Matthias Schabel wrote:
>>template< typename Y >
>>Y idealGasLaw( pascals<Y> p, litres<Y> v, kelvins<Y> t );
>>
>>?
>>
>>Kelvins should _themselves_ 'know' that they are a temperature type. And
>>if I threw Celsius at it, it should know what to do, too.
>
>This is a perfect opportunity for template typedefs; it would be great to
>just be able to do something like
>
>template<class Y> typedef
>dimensioned_quantity<Y,dimensioned_unit<si_model,temperature_unit> >
>kelvin<Y>;
>
>That would make me a happy person...

It is possible to emulate template typedefs (c.f. allocator< T >::rebind< U
>, and others). The example above would be:

template< typename Y >
struct kelvin
{
   typedef
dimensioned_quantity<Y,dimensioned_unit<si_model,temperature_unit> >
      type;
};

leading to the slightly more verbose

template< typename Y >
Y idealGasLaw( pascals<Y>::type p, litres<Y>::type v, kelvins<Y>::type t );

But this is becoming more and more common, especially when dealing with
Boost.MPL. For me, I don't have a problem with this style, but what do other
people feel about it?

Regards,
Reece

_________________________________________________________________
Express yourself with cool new emoticons http://www.msn.co.uk/specials/myemo


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