Boost logo

Boost :

From: Matthias Schabel (pinhead_at_[hidden])
Date: 2002-09-27 10:40:05


> doing Barton & Nackman's templated approach to tracking m, l, and t? It
> was mentioned in Scott Meyers forward to Andrei Alexandrescu's book.
>
> Should that be attempted, then we could (of course) include the
 measurement
> system (and possibly even convert automagically between them).
>
> That has been a 'dream' of mine ever since I first saw "object oriented"
>

 This has been done at FermiLab in the SIunits library. It might be
 interesting to see about
 incorporating this into boost - it claims to (and, appears to, from some
 limited experimentation) not incur any
 runtime overhead and correctly resolves units through complex expressions.
 You can find the code at

 http://fermitools.fnal.gov/abstracts/siunits/abstract.html

 It's actually pretty cool - allows definition of new unit systems (and
 provides SI, cosmological, quantum, and
 I think CGS systems) Incorporation of this would allow unit checking when
 using dimensioned physical
 constants. As far as structuring the constants, how about breaking it up
 something like:

 namespace constants
 {
     namespace mathematical
     {
         template<class T> static T e() { return 2.7182; }
     }

     namespace physical
     {
         namespace fundamental
         {
             template<class T> static T c() { return 2.99e5; }
          }

         namespace quantum
         { ... }
      }

     namespace geophysical { }
 }

 This would allow using declarations in sections of code which heavily use
 constants from particular categories and allows
 use of different conventions for say sqrt(-1) ( i() in physics parlance,
j()
 in electrical engineering)...

Matthias


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