Boost logo

Boost :

From: Steven Watanabe (steven_at_[hidden])
Date: 2007-03-26 17:20:14


Phil Endecott <spam_from_boost_dev <at>> writes:

> I have spent a couple of hours looking at the units library. This is
> not a full review as I have not been able to compile my simple example
> in the time that I have available.
> <snip>
> so I concluded that the dimensions of power are mass length time^-3 and
> hence of heat transfer coefficient are mass time^-3 temperature^-1
> length^-1, and wrote this:
> typedef
> heat_transfer_coefficient_t;

 typedef unit<
> heat_transfer_coefficient_t;


 typedef divide_typeof_helper<
>::type heat_transfer_coefficient_t;

> Defining the unit was easier:
> const heat_transfer_coefficient_t watts_per_square_meter_per_celcis
> = watts / square_meter / kelvin;
> But this fails to compile, with this error:
> error: conversion from
> <snip>
> Presumably this is because I have got something wrong in my working. I
> gave up at this point.
> For this library to be useful for me, it needs to be quick to learn and
> easy to apply. Working only with the included units it does look like
> it would work reasonably well, but in the situation I have described
> above it was quickly obvious that it was taking more effort to apply it
> to my program than the benefit that would result.
> There are two areas that I was interested in looking in more detail at,
> and I encourage other reviewers who get further than me to have a look
> at them:
> 1. What is the effect on compile time? I used #if to switch between
> units and plain floats.

It depends on how many different units you are using.

> 2. Is there any increase in object file size? I know there shouldn't
> be, but it would be interesting to know for sure.

suppose you have a function

  template<class T>
  T f(const T&);

Now, if you use float will only be instantiated once.
If, on the other hand you use quantity f will be instantiated
for every unit.

> 3. Are the error messages comprehensible? The one show above is not
> great, but it could have been worse; there are some Boost libraries
> which I find unusable because of the volumne and inpenetrability of the
> error messages that result from a simple typo (though the compiler must
> share the blame for this).

The main problem is that the types store a tremendous amount
of information and therefore have very long names.

> Finally some random notes from my reading of the documentation:
> - "io" is a misnomer since it only does output, as far as I can see.

Uh. right.

> - I tend to refer to temperature differences in Celcius, rather than
> Kelvin. There is an obvious issue when dealing with absolute
> temperatures though.
> - "Meter" vs. "Metre". My dictionary says "meter" is "chiefly U.S.".
> My physics books say "metre" consistently. Presumably both can be included.

They are.

> - Am I the only person who uses capital letters for units named after
> people? Hmm, maybe I am.

In Christ,
Steven Watanabe

Boost list run by bdawes at, gregod at, cpdaniel at, john at