Boost logo

Boost Users :

Subject: Re: [Boost-users] [Boost.Units] quantity<unit> problem with template specialisation algorithm?
From: Paul A. Bristow (pbristow_at_[hidden])
Date: 2010-05-14 05:18:08


> -----Original Message-----
> From: boost-users-bounces_at_[hidden] [mailto:boost-users-bounces_at_[hidden]] On Behalf Of Steven Watanabe
> Sent: Thursday, May 13, 2010 6:46 PM
> To: boost-users_at_[hidden]
> Subject: Re: [Boost-users] [Boost.Units] quantity<unit> problem with template specialisation algorithm?
>
> AMDG
>
> Thomas Shorrock wrote:
> > many thankyous to the developers of Boost.Units and Boost libraries generally,
> > I have been using them for a few years now and this is my first difficulty.
> >
> > I have been having some problems when using template specialisation (g++ 4.4.3) with Boost.Units (Boost 1_42_0).
> > When calling a specialised template function I have found that I need to be very careful with the argument,
> >
> > In short,
> > specialised_templated_function(1.0 * boost::units::si::metre) works fine
> > specialised_templated_function(1 * boost::units::si::metre) specialised function is not found (default tried)
> >
>
> 1 * boost::units::si::metre returns
> boost::units::quantity<boost::units::si::length, int>,
> which doesn't match boost::units::quantity<boost::units::si::lenth, double>.
> You would have the same problem if you used built-in types directly.

As ever, Steven is quite right about this, but I have also plopped right into this pit myself in my first fumbles with
Boost.Units.

It could certain use a bit louder warning in the docs - I'm sure I won't be the last to make this mistake.

Is there a reason why int isn't 'supported' (for built-in types at least)?

Is it to avoid potential bloat (short, long, unsigned ..)? Or just too much hassle?

Paul

---
Paul A. Bristow
Prizet Farmhouse
Kendal, UK   LA8 8AB
+44 1539 561830, mobile +44 7714330204
pbristow_at_[hidden]

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net