Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

Chapter 43. Boost.Units 1.1.0

Matthias C. Schabel

Steven Watanabe

Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

Table of Contents

Introduction
Quick Start
Dimensional Analysis
Units
Base Units
Scaled Base Units
Scaled Units
Quantities
Heterogeneous Operators
Conversions
Construction and Conversion of Quantities
Examples
Dimension Example
Unit Example
Quantity Example
Kitchen Sink Example using SI units
Conversion Example
User Defined Types
Complex Example
Performance Example
Radar Beam Height
Heterogeneous Unit Example
Absolute and Relative Temperature Example
Runtime Conversion Factor Example
Units with Non-base Dimensions
Output for Composite Units
Automatically Scaled Units
Conversion Factor
Runtime Units
Interoperability with Boost.Lambda
Utilities
Metaprogramming Classes
Metaprogramming Predicates
Reference
Units Reference
Dimensions Reference
SI System Reference
CGS System Reference
Trigonometry and Angle System Reference
Temperature System Reference
Information System Reference
Abstract System Reference
Base Units by Category
Alphabetical Listing of Base Units
Installation
FAQ
How does one distinguish between quantities that are physically different but have the same units (such as energy and torque)?
Angles are treated as units
Why are there homogeneous systems? Aren't heterogeneous systems sufficient?
Why can't I construct a quantity directly from the value type?
Why are conversions explicit by default?
Acknowledgements
Help Wanted
Version Info
Release Notes
TODO

The Boost.Units library is a C++ implementation of dimensional analysis in a general and extensible manner, treating it as a generic compile-time metaprogramming problem. With appropriate compiler optimization, no runtime execution cost is introduced, facilitating the use of this library to provide dimension checking in performance-critical code. Support for units and quantities (defined as a unit and associated value) for arbitrary unit system models and arbitrary value types is provided, as is a fine-grained general facility for unit conversions. Complete SI and CGS unit systems are provided, along with systems for angles measured in degrees, radians, gradians, and revolutions and systems for temperatures measured in Kelvin, degrees Celsius and degrees Fahrenheit. The library architecture has been designed with flexibility and extensibility in mind; demonstrations of the ease of adding new units and unit conversions are provided in the examples.

In order to enable complex compile-time dimensional analysis calculations with no runtime overhead, Boost.Units relies heavily on the Boost Metaprogramming Library (MPL) and on template metaprogramming techniques, and is, as a consequence, fairly demanding of compiler compliance to ISO standards. At present, it has been successfully compiled and tested on the following compilers/platforms :

  1. g++ 4.0.1 on Mac OSX 10.4
  2. Intel CC 9.1, 10.0, and 10.1 on Mac OSX 10.4
  3. g++ 3.4.4, 4.2.3, and 4.3.0 on Windows XP
  4. Microsoft Visual C++ 7.1, 8.0, and 9.0 on Windows XP
  5. Comeau 4.3.10.1 beta2 on Windows XP
  6. Metrowerks CodeWarrior 9.2 on Windows XP.
  7. Sun CC 5.9 on Solaris and Linux

The following compilers/platforms are known not to work :

  1. g++ 3.3.x
  2. Microsoft Visual C++ 6.0 on Windows XP
  3. Microsoft Visual C++ 7.0 on Windows XP
  4. Metrowerks CodeWarrior 8.0 on Windows XP.
  5. All versions of Borland.

Last revised: April 17, 2017 at 02:30:57 GMT


PrevUpHomeNext