Boost logo

Boost :

From: Andrey Semashev (andysem_at_[hidden])
Date: 2007-01-16 16:51:03

Hello Matthias,

Tuesday, January 16, 2007, 7:42:39 AM, you wrote:

> Paul,


>> Explicit is fine with me, but can you ease the pain?
>> In practice, many would usually be working only with SI units, so
>> this would simplify to
>> quantity<double, length> q1(1.5 * meters);

> Right now you get this syntax is you (gasp) do using namespace SI;

>> Or could we have SI as the template class default, or some global
>> choice? macro?

> This is somewhat problematic with the current implementation because
> the unit system is encapsulated as a template argument of the unit,
> which is itself a template argument of quantity. I'll have to think
> about it a bit more...

Maybe a simple "using namespace SI" would be sufficient? IMO, macros
should be a kind of last resort and may eventually bring more problems
than convenience.


>> And/or some typedefs perhaps ? Like
>> typedef quantity<double,SI::length> length_type;

> I already have typedefs for units themselves:

> typedef unit<SI::system,length_type> length;

> but would be happy to add quantity typedefs, too. You're probably
> right that a simple double-precision SI unit set is going to be by
> far the predominant use case in practical code... Maybe

> typedef quantity<double,SI::length> SI_length_q;

> (analogous to time_t nomenclature)? Or I could rename the unit
> typedefs to length_unit, etc... to free up the simpler typedefs:

> typedef unit<SI::system,length_type> length_unit;

> typedef quantity<double,SI::length_unit> length;

> I'd be happy to hear additional opinions/ideas about this point...

I think these typedefs, if they are necessary (I'm not quite sure they
are, though), should have quite distinctive and telling names and
should reside in system namespaces, like SI. Even when importing the
whole SI namespace via "using" the library names should not conflict
with commonly used symbols, such as "length" or "time".


namespace SI {

  typedef quantity<double, length> length_quantity_t;
  typedef unit<system, length_type> length_unit_t;



Best regards,
 Andrey                            mailto:andysem_at_[hidden]

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