summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/units
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
commit19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch)
tree42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/boost/libs/units
parentInitial commit. (diff)
downloadceph-6d07fdb6bb33b1af39833b850bb6cf8af79fe293.tar.xz
ceph-6d07fdb6bb33b1af39833b850bb6cf8af79fe293.zip
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boost/libs/units')
-rw-r--r--src/boost/libs/units/README.md38
-rw-r--r--src/boost/libs/units/boost.css65
-rwxr-xr-xsrc/boost/libs/units/covscan.sh38
-rw-r--r--src/boost/libs/units/example/Jamfile.v225
-rw-r--r--src/boost/libs/units/example/autoprefixes.cpp148
-rw-r--r--src/boost/libs/units/example/complex.cpp421
-rw-r--r--src/boost/libs/units/example/composite_output.cpp116
-rw-r--r--src/boost/libs/units/example/conversion.cpp124
-rw-r--r--src/boost/libs/units/example/conversion_factor.cpp76
-rw-r--r--src/boost/libs/units/example/dimension.cpp117
-rw-r--r--src/boost/libs/units/example/heterogeneous_unit.cpp87
-rw-r--r--src/boost/libs/units/example/information.cpp100
-rw-r--r--src/boost/libs/units/example/kitchen_sink.cpp542
-rw-r--r--src/boost/libs/units/example/lambda.cpp157
-rw-r--r--src/boost/libs/units/example/measurement.hpp344
-rw-r--r--src/boost/libs/units/example/non_base_dimension.cpp78
-rw-r--r--src/boost/libs/units/example/performance.cpp395
-rw-r--r--src/boost/libs/units/example/quantity.cpp128
-rw-r--r--src/boost/libs/units/example/quaternion.cpp232
-rw-r--r--src/boost/libs/units/example/radar_beam_height.cpp167
-rw-r--r--src/boost/libs/units/example/runtime_conversion_factor.cpp72
-rw-r--r--src/boost/libs/units/example/runtime_unit.cpp116
-rw-r--r--src/boost/libs/units/example/runtime_unit_input.txt13
-rw-r--r--src/boost/libs/units/example/systems.cpp1072
-rw-r--r--src/boost/libs/units/example/temperature.cpp98
-rw-r--r--src/boost/libs/units/example/test_system.hpp153
-rw-r--r--src/boost/libs/units/example/tutorial.cpp95
-rw-r--r--src/boost/libs/units/example/unit.cpp73
-rw-r--r--src/boost/libs/units/images/form_0.pngbin0 -> 186 bytes
-rw-r--r--src/boost/libs/units/images/form_1.pngbin0 -> 482 bytes
-rw-r--r--src/boost/libs/units/images/form_10.pngbin0 -> 466 bytes
-rw-r--r--src/boost/libs/units/images/form_11.pngbin0 -> 460 bytes
-rw-r--r--src/boost/libs/units/images/form_12.pngbin0 -> 313 bytes
-rw-r--r--src/boost/libs/units/images/form_13.pngbin0 -> 303 bytes
-rw-r--r--src/boost/libs/units/images/form_14.pngbin0 -> 344 bytes
-rw-r--r--src/boost/libs/units/images/form_15.pngbin0 -> 380 bytes
-rw-r--r--src/boost/libs/units/images/form_2.pngbin0 -> 449 bytes
-rw-r--r--src/boost/libs/units/images/form_3.pngbin0 -> 707 bytes
-rw-r--r--src/boost/libs/units/images/form_4.pngbin0 -> 192 bytes
-rw-r--r--src/boost/libs/units/images/form_5.pngbin0 -> 897 bytes
-rw-r--r--src/boost/libs/units/images/form_6.pngbin0 -> 907 bytes
-rw-r--r--src/boost/libs/units/images/form_7.pngbin0 -> 367 bytes
-rw-r--r--src/boost/libs/units/images/form_8.pngbin0 -> 3868 bytes
-rw-r--r--src/boost/libs/units/images/form_9.pngbin0 -> 405 bytes
-rw-r--r--src/boost/libs/units/index.html22
-rw-r--r--src/boost/libs/units/meta/libraries.json16
-rw-r--r--src/boost/libs/units/test/Jamfile.v278
-rw-r--r--src/boost/libs/units/test/check_conversion_defs.cpp159
-rw-r--r--src/boost/libs/units/test/fail_add_temperature.cpp38
-rw-r--r--src/boost/libs/units/test/fail_adl_detail.cpp48
-rw-r--r--src/boost/libs/units/test/fail_base_dimension.cpp32
-rw-r--r--src/boost/libs/units/test/fail_heterogeneous_unit.cpp46
-rw-r--r--src/boost/libs/units/test/fail_implicit_conversion.cpp36
-rw-r--r--src/boost/libs/units/test/fail_quantity_add.cpp35
-rw-r--r--src/boost/libs/units/test/fail_quantity_add_assign.cpp36
-rw-r--r--src/boost/libs/units/test/fail_quantity_assign.cpp36
-rw-r--r--src/boost/libs/units/test/fail_quantity_construct.cpp35
-rw-r--r--src/boost/libs/units/test/fail_quantity_non_unit.cpp37
-rw-r--r--src/boost/libs/units/test/fail_quantity_scalar_add.cpp35
-rw-r--r--src/boost/libs/units/test/fail_quantity_scalar_sub.cpp35
-rw-r--r--src/boost/libs/units/test/fail_quantity_sub_assign.cpp36
-rw-r--r--src/boost/libs/units/test/fail_quantity_subtract.cpp35
-rw-r--r--src/boost/libs/units/test/fail_quantity_unit_add.cpp35
-rw-r--r--src/boost/libs/units/test/fail_quantity_unit_subtract.cpp35
-rw-r--r--src/boost/libs/units/test/fail_scalar_quantity_add.cpp35
-rw-r--r--src/boost/libs/units/test/fail_scalar_quantity_sub.cpp35
-rw-r--r--src/boost/libs/units/test/fail_unit_quantity_add.cpp35
-rw-r--r--src/boost/libs/units/test/fail_unit_quantity_subtract.cpp35
-rw-r--r--src/boost/libs/units/test/test_absolute.cpp68
-rw-r--r--src/boost/libs/units/test/test_base_dimension.cpp31
-rw-r--r--src/boost/libs/units/test/test_cmath.cpp173
-rw-r--r--src/boost/libs/units/test/test_complicated_system.cpp96
-rw-r--r--src/boost/libs/units/test/test_constants.cpp87
-rw-r--r--src/boost/libs/units/test/test_conversion.cpp110
-rw-r--r--src/boost/libs/units/test/test_custom_unit.cpp84
-rw-r--r--src/boost/libs/units/test/test_default_conversion.cpp78
-rw-r--r--src/boost/libs/units/test/test_dimensionless_ice1.cpp26
-rw-r--r--src/boost/libs/units/test/test_dimensionless_ice2.cpp25
-rw-r--r--src/boost/libs/units/test/test_dimensionless_quantity.cpp216
-rw-r--r--src/boost/libs/units/test/test_header.hpp126
-rw-r--r--src/boost/libs/units/test/test_implicit_conversion.cpp113
-rw-r--r--src/boost/libs/units/test/test_information_units.cpp242
-rw-r--r--src/boost/libs/units/test/test_lambda.cpp269
-rw-r--r--src/boost/libs/units/test/test_limits.cpp127
-rw-r--r--src/boost/libs/units/test/test_mixed_value_types.cpp22
-rw-r--r--src/boost/libs/units/test/test_negative_denominator.cpp32
-rw-r--r--src/boost/libs/units/test/test_output.cpp499
-rw-r--r--src/boost/libs/units/test/test_predicates.cpp100
-rw-r--r--src/boost/libs/units/test/test_quantity.cpp203
-rw-r--r--src/boost/libs/units/test/test_reduce_unit.cpp30
-rw-r--r--src/boost/libs/units/test/test_scaled_conversion.cpp66
-rw-r--r--src/boost/libs/units/test/test_scaled_unit.cpp76
-rw-r--r--src/boost/libs/units/test/test_sqrt_scaled_unit.cpp48
-rw-r--r--src/boost/libs/units/test/test_trig.cpp79
-rw-r--r--src/boost/libs/units/test/test_unit.cpp67
-rw-r--r--src/boost/libs/units/test/test_unscale.cpp58
-rw-r--r--src/boost/libs/units/test_headers/Jamfile.v256
-rw-r--r--src/boost/libs/units/test_headers/main.cpp12
-rw-r--r--src/boost/libs/units/test_headers/test.cpp19
-rw-r--r--src/boost/libs/units/tutorial/tutorial_1.cpp314
100 files changed, 9647 insertions, 0 deletions
diff --git a/src/boost/libs/units/README.md b/src/boost/libs/units/README.md
new file mode 100644
index 000000000..685cb464a
--- /dev/null
+++ b/src/boost/libs/units/README.md
@@ -0,0 +1,38 @@
+Boost.Units
+===========
+
+Boost.Units, part of collection of the [Boost C++ Libraries](http://github.com/boostorg),
+implements 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.
+
+### Directories
+
+* **doc** - QuickBook documentation sources
+* **example** - examples
+* **images** - images for documention
+* **include** - Interface headers
+* **test** - unit tests
+* **test_headers** - unit tests for self containment of headers
+* **tutorial** - tutorial
+
+### Test results
+
+@ | Travis | AppVeyor
+--------|-------------|---------
+master | [![Build Status](https://travis-ci.org/boostorg/units.svg?branch=master)](https://travis-ci.org/boostorg/units) | [![Build Status](https://ci.appveyor.com/api/projects/status/github/boostorg/units?branch=master&svg=true)](https://ci.appveyor.com/project/boostorg/units)
+develop | [![Build Status](https://travis-ci.org/boostorg/units.svg)](https://travis-ci.org/boostorg/units) | [![Build Status](https://ci.appveyor.com/api/projects/status/github/boostorg/units?svg=true)](https://ci.appveyor.com/project/boostorg/units)
+
+<a href="https://scan.coverity.com/projects/boostorg-units">
+ <img alt="Coverity Scan Build Status"
+ src="https://img.shields.io/coverity/scan/14037.svg"/>
+</a>
+
+### More information
+
+* [Documentation](http://boost.org/libs/units)
+
+### License
+
+Distributed under the [Boost Software License, Version 1.0](http://www.boost.org/LICENSE_1_0.txt).
diff --git a/src/boost/libs/units/boost.css b/src/boost/libs/units/boost.css
new file mode 100644
index 000000000..9f8d4bda8
--- /dev/null
+++ b/src/boost/libs/units/boost.css
@@ -0,0 +1,65 @@
+/*=============================================================================
+ Copyright 2002 William E. Kempf
+ Distributed under the Boost Software License, Version 1.0. (See accompany-
+ ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+=============================================================================*/
+
+H1
+{
+ FONT-SIZE: 200%;
+ COLOR: #00008B;
+}
+H2
+{
+ FONT-SIZE: 150%;
+}
+H3
+{
+ FONT-SIZE: 125%;
+}
+H4
+{
+ FONT-SIZE: 108%;
+}
+BODY
+{
+ FONT-SIZE: 100%;
+ BACKGROUND-COLOR: #ffffff;
+}
+PRE
+{
+ MARGIN-LEFT: 2em;
+ FONT-FAMILY: Courier,
+ monospace;
+}
+CODE
+{
+ FONT-FAMILY: Courier,
+ monospace;
+}
+CODE.as_pre
+{
+ white-space: pre;
+}
+.index
+{
+ TEXT-ALIGN: left;
+}
+.page-index
+{
+ TEXT-ALIGN: left;
+}
+.definition
+{
+ TEXT-ALIGN: left;
+}
+.footnote
+{
+ FONT-SIZE: 66%;
+ VERTICAL-ALIGN: super;
+ TEXT-DECORATION: none;
+}
+.function-semantics
+{
+ CLEAR: left;
+} \ No newline at end of file
diff --git a/src/boost/libs/units/covscan.sh b/src/boost/libs/units/covscan.sh
new file mode 100755
index 000000000..88e08d3e6
--- /dev/null
+++ b/src/boost/libs/units/covscan.sh
@@ -0,0 +1,38 @@
+#! /bin/bash
+#
+# Copyright 2017 James E. King, III
+# 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)
+#
+# Bash script to run in travis to perform a Coverity Scan build
+#
+
+#
+# Environment Variables
+#
+# COVERITY_SCAN_NOTIFICATION_EMAIL - email address to notify
+# COVERITY_SCAN_TOKEN - the Coverity Scan token (should be secure)
+# SELF - the boost libs directory name
+
+set -ex
+
+pushd /tmp
+rm -rf coverity_tool.tgz cov-analysis*
+wget -nv https://scan.coverity.com/download/linux64 --post-data "token=$COVERITY_SCAN_TOKEN&project=boostorg/$SELF" -O coverity_tool.tgz
+tar xzf coverity_tool.tgz
+COVBIN=$(echo $(pwd)/cov-analysis*/bin)
+export PATH=$COVBIN:$PATH
+popd
+
+cd libs/$SELF/test
+../../../b2 toolset=gcc clean
+rm -rf cov-int/
+cov-build --dir cov-int ../../../b2 toolset=gcc -q -j3
+tar cJf cov-int.tar.xz cov-int/
+curl --form token="$COVERITY_SCAN_TOKEN" \
+ --form email="$COVERITY_SCAN_NOTIFICATION_EMAIL" \
+ --form file=@cov-int.tar.xz \
+ --form version="$(git describe --tags)" \
+ --form description="boostorg/$SELF" \
+ https://scan.coverity.com/builds?project="boostorg/$SELF"
diff --git a/src/boost/libs/units/example/Jamfile.v2 b/src/boost/libs/units/example/Jamfile.v2
new file mode 100644
index 000000000..b918205ac
--- /dev/null
+++ b/src/boost/libs/units/example/Jamfile.v2
@@ -0,0 +1,25 @@
+# Jamfile.v2
+#
+# Copyright (c) 2007-2008
+# 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
+
+import testing ;
+import path ;
+
+project boost/units/example :
+ : requirements <include>$(BOOST_ROOT) <include>../../.. <warnings>all
+;
+
+files = [ path.glob . : *.cpp : performance.* runtime_unit.* ] ;
+
+for local file in $(files)
+{
+ run $(file) ;
+}
+
+compile performance.cpp ;
+run runtime_unit.cpp : <runtime_unit_input.txt ;
diff --git a/src/boost/libs/units/example/autoprefixes.cpp b/src/boost/libs/units/example/autoprefixes.cpp
new file mode 100644
index 000000000..9966766c6
--- /dev/null
+++ b/src/boost/libs/units/example/autoprefixes.cpp
@@ -0,0 +1,148 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2008 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)
+
+/**
+\file
+
+\brief Example of using autoprefixes.
+
+\details
+Example of using engineering (10^3) and binary (2^10) autoprefixes.
+
+Output:
+@verbatim
+autoprefixes.cpp
+using native typeof
+Linking...
+Embedding manifest...
+Autorun "j:\Cpp\Misc\debug\autoprefixes.exe"
+2.345 m
+2.345 km
+5.49902 MJ
+5.49902 megajoule
+2.048 kb
+2 Kib
+2345.6
+23456
+2345.6
+23456
+m
+meter
+0
+1
+@endverbatim
+//[autoprefixes_output
+
+//] [/autoprefixes_output
+
+**/
+
+#include <iostream>
+
+#include <boost/units/io.hpp>
+#include <boost/units/pow.hpp>
+#include <boost/units/systems/si.hpp>
+#include <boost/units/systems/si/io.hpp>
+#include <boost/units/quantity.hpp>
+
+struct byte_base_unit : boost::units::base_unit<byte_base_unit, boost::units::dimensionless_type, 3>
+{
+ static constexpr const char* name() { return("byte"); }
+ static constexpr const char* symbol() { return("b"); }
+};
+
+struct thing_base_unit : boost::units::base_unit<thing_base_unit, boost::units::dimensionless_type, 4>
+{
+ static constexpr const char* name() { return("thing"); }
+ static constexpr const char* symbol() { return(""); }
+};
+
+struct euro_base_unit : boost::units::base_unit<euro_base_unit, boost::units::dimensionless_type, 5>
+{
+ static constexpr const char* name() { return("EUR"); }
+ static constexpr const char* symbol() { return("€"); }
+};
+
+int main()
+{
+ using std::cout;
+ using std::endl;
+
+ using namespace boost::units;
+ using namespace boost::units::si;
+
+ //[autoprefixes_snippet_1
+ using boost::units::binary_prefix;
+ using boost::units::engineering_prefix;
+ using boost::units::no_prefix;
+
+ quantity<length> l = 2.345 * meters; // A quantity of length, in units of meters.
+ cout << engineering_prefix << l << endl; // Outputs "2.345 m".
+ l = 1000.0 * l; // Increase it by 1000, so expect a k prefix.
+ // Note that a double 1000.0 is required - an integer will fail to compile.
+ cout << engineering_prefix << l << endl; // Output autoprefixed with k to "2.345 km".
+
+ quantity<energy> e = kilograms * pow<2>(l / seconds); // A quantity of energy.
+ cout << engineering_prefix << e << endl; // 5.49902 MJ
+ cout << name_format << engineering_prefix << e << endl; // 5.49902 megaJoule
+ //] [/autoprefixes_snippet_1]
+
+ //[autoprefixes_snippet_2
+ // Don't forget that the units name or symbol format specification is persistent.
+ cout << symbol_format << endl; // Resets the format to the default symbol format.
+
+ quantity<byte_base_unit::unit_type> b = 2048. * byte_base_unit::unit_type();
+ cout << engineering_prefix << b << endl; // 2.048 kb
+ cout << symbol_format << binary_prefix << b << endl; // "2 Kib"
+ //] [/autoprefixes_snippet_2]
+
+ // Note that scalar dimensionless values are *not* prefixed automatically by the engineering_prefix or binary_prefix iostream manipulators.
+ //[autoprefixes_snippet_3
+ const double s1 = 2345.6;
+ const long x1 = 23456;
+ cout << engineering_prefix << s1 << endl; // 2345.6
+ cout << engineering_prefix << x1 << endl; // 23456
+
+ cout << binary_prefix << s1 << endl; // 2345.6
+ cout << binary_prefix << x1 << endl; // 23456
+ //] [/autoprefixes_snippet_3]
+
+ //[autoprefixes_snippet_4
+ const length L; // A unit of length (but not a quantity of length).
+ cout << L << endl; // Default length unit is meter,
+ // but default is symbol format so output is just "m".
+ cout << name_format << L << endl; // default length name is "meter".
+ //] [/autoprefixes_snippet_4]
+
+ //[autoprefixes_snippet_5
+ no_prefix(cout); // Clear any prefix flag.
+ cout << no_prefix << endl; // Clear any prefix flag using `no_prefix` manipulator.
+ //] [/autoprefixes_snippet_5]
+
+ //[autoprefixes_snippet_6
+ cout << boost::units::get_autoprefix(cout) << endl; // 8 is `autoprefix_binary` from `enum autoprefix_mode`.
+ cout << boost::units::get_format(cout) << endl; // 1 is `name_fmt` from `enum format_mode`.
+ //] [/autoprefixes_snippet_6]
+
+
+ quantity<thing_base_unit::unit_type> t = 2048. * thing_base_unit::unit_type();
+ cout << name_format << engineering_prefix << t << endl; // 2.048 kilothing
+ cout << symbol_format << engineering_prefix << t << endl; // 2.048 k
+
+ cout << binary_prefix << t << endl; // "2 Ki"
+
+ quantity<euro_base_unit::unit_type> ce = 2048. * euro_base_unit::unit_type();
+ cout << name_format << engineering_prefix << ce << endl; // 2.048 kiloEUR
+ cout << symbol_format << engineering_prefix << ce << endl; // 2.048 k€
+
+
+ return 0;
+} // int main()
+
diff --git a/src/boost/libs/units/example/complex.cpp b/src/boost/libs/units/example/complex.cpp
new file mode 100644
index 000000000..d3579a064
--- /dev/null
+++ b/src/boost/libs/units/example/complex.cpp
@@ -0,0 +1,421 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2008 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)
+
+/**
+\file
+
+\brief complex.cpp
+
+\details
+Demonstrate a complex number class that functions correctly with quantities.
+
+Output:
+@verbatim
+
+//[complex_output_1
++L = 2 + 1 i m
+-L = -2 + -1 i m
+L+L = 4 + 2 i m
+L-L = 0 + 0 i m
+L*L = 3 + 4 i m^2
+L/L = 1 + 0 i dimensionless
+L^3 = 2 + 11 i m^3
+L^(3/2) = 2.56713 + 2.14247 i m^(3/2)
+3vL = 1.29207 + 0.201294 i m^(1/3)
+(3/2)vL = 1.62894 + 0.520175 i m^(2/3)
+//]
+
+//[complex_output_2
++L = 2 m + 1 m i
+-L = -2 m + -1 m i
+L+L = 4 m + 2 m i
+L-L = 0 m + 0 m i
+L*L = 3 m^2 + 4 m^2 i
+L/L = 1 dimensionless + 0 dimensionless i
+L^3 = 2 m^3 + 11 m^3 i
+L^(3/2) = 2.56713 m^(3/2) + 2.14247 m^(3/2) i
+3vL = 1.29207 m^(1/3) + 0.201294 m^(1/3) i
+(3/2)vL = 1.62894 m^(2/3) + 0.520175 m^(2/3) i
+//]
+
+@endverbatim
+**/
+
+#include <cmath>
+#include <complex>
+#include <iostream>
+
+#include <boost/mpl/list.hpp>
+
+#include <boost/units/io.hpp>
+#include <boost/units/pow.hpp>
+#include <boost/units/quantity.hpp>
+
+#include "test_system.hpp"
+
+//[complex_class_snippet_1
+namespace boost {
+
+namespace units {
+
+/// replacement complex class
+template<class T>
+class complex
+{
+ public:
+ typedef complex<T> this_type;
+
+ constexpr complex(const T& r = 0,const T& i = 0) : r_(r),i_(i) { }
+ constexpr complex(const this_type& source) : r_(source.r_),i_(source.i_) { }
+
+ constexpr this_type& operator=(const this_type& source)
+ {
+ if (this == &source) return *this;
+
+ r_ = source.r_;
+ i_ = source.i_;
+
+ return *this;
+ }
+
+ constexpr T& real() { return r_; }
+ constexpr T& imag() { return i_; }
+
+ constexpr const T& real() const { return r_; }
+ constexpr const T& imag() const { return i_; }
+
+ constexpr this_type& operator+=(const T& val)
+ {
+ r_ += val;
+ return *this;
+ }
+
+ constexpr this_type& operator-=(const T& val)
+ {
+ r_ -= val;
+ return *this;
+ }
+
+ constexpr this_type& operator*=(const T& val)
+ {
+ r_ *= val;
+ i_ *= val;
+ return *this;
+ }
+
+ constexpr this_type& operator/=(const T& val)
+ {
+ r_ /= val;
+ i_ /= val;
+ return *this;
+ }
+
+ constexpr this_type& operator+=(const this_type& source)
+ {
+ r_ += source.r_;
+ i_ += source.i_;
+ return *this;
+ }
+
+ constexpr this_type& operator-=(const this_type& source)
+ {
+ r_ -= source.r_;
+ i_ -= source.i_;
+ return *this;
+ }
+
+ constexpr this_type& operator*=(const this_type& source)
+ {
+ *this = *this * source;
+ return *this;
+ }
+
+ constexpr this_type& operator/=(const this_type& source)
+ {
+ *this = *this / source;
+ return *this;
+ }
+
+ private:
+ T r_,i_;
+};
+
+}
+
+}
+
+#if BOOST_UNITS_HAS_BOOST_TYPEOF
+
+#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
+
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::units::complex, 1)
+
+#endif
+
+namespace boost {
+
+namespace units {
+
+template<class X>
+constexpr
+complex<typename unary_plus_typeof_helper<X>::type>
+operator+(const complex<X>& x)
+{
+ typedef typename unary_plus_typeof_helper<X>::type type;
+
+ return complex<type>(x.real(),x.imag());
+}
+
+template<class X>
+constexpr
+complex<typename unary_minus_typeof_helper<X>::type>
+operator-(const complex<X>& x)
+{
+ typedef typename unary_minus_typeof_helper<X>::type type;
+
+ return complex<type>(-x.real(),-x.imag());
+}
+
+template<class X,class Y>
+constexpr
+complex<typename add_typeof_helper<X,Y>::type>
+operator+(const complex<X>& x,const complex<Y>& y)
+{
+ typedef typename boost::units::add_typeof_helper<X,Y>::type type;
+
+ return complex<type>(x.real()+y.real(),x.imag()+y.imag());
+}
+
+template<class X,class Y>
+constexpr
+complex<typename boost::units::subtract_typeof_helper<X,Y>::type>
+operator-(const complex<X>& x,const complex<Y>& y)
+{
+ typedef typename boost::units::subtract_typeof_helper<X,Y>::type type;
+
+ return complex<type>(x.real()-y.real(),x.imag()-y.imag());
+}
+
+template<class X,class Y>
+constexpr
+complex<typename boost::units::multiply_typeof_helper<X,Y>::type>
+operator*(const complex<X>& x,const complex<Y>& y)
+{
+ typedef typename boost::units::multiply_typeof_helper<X,Y>::type type;
+
+ return complex<type>(x.real()*y.real() - x.imag()*y.imag(),
+ x.real()*y.imag() + x.imag()*y.real());
+
+// fully correct implementation has more complex return type
+//
+// typedef typename boost::units::multiply_typeof_helper<X,Y>::type xy_type;
+//
+// typedef typename boost::units::add_typeof_helper<
+// xy_type,xy_type>::type xy_plus_xy_type;
+// typedef typename
+// boost::units::subtract_typeof_helper<xy_type,xy_type>::type
+// xy_minus_xy_type;
+//
+// BOOST_STATIC_ASSERT((boost::is_same<xy_plus_xy_type,
+// xy_minus_xy_type>::value == true));
+//
+// return complex<xy_plus_xy_type>(x.real()*y.real()-x.imag()*y.imag(),
+// x.real()*y.imag()+x.imag()*y.real());
+}
+
+template<class X,class Y>
+constexpr
+complex<typename boost::units::divide_typeof_helper<X,Y>::type>
+operator/(const complex<X>& x,const complex<Y>& y)
+{
+ // naive implementation of complex division
+ typedef typename boost::units::divide_typeof_helper<X,Y>::type type;
+
+ return complex<type>((x.real()*y.real()+x.imag()*y.imag())/
+ (y.real()*y.real()+y.imag()*y.imag()),
+ (x.imag()*y.real()-x.real()*y.imag())/
+ (y.real()*y.real()+y.imag()*y.imag()));
+
+// fully correct implementation has more complex return type
+//
+// typedef typename boost::units::multiply_typeof_helper<X,Y>::type xy_type;
+// typedef typename boost::units::multiply_typeof_helper<Y,Y>::type yy_type;
+//
+// typedef typename boost::units::add_typeof_helper<xy_type, xy_type>::type
+// xy_plus_xy_type;
+// typedef typename boost::units::subtract_typeof_helper<
+// xy_type,xy_type>::type xy_minus_xy_type;
+//
+// typedef typename boost::units::divide_typeof_helper<
+// xy_plus_xy_type,yy_type>::type xy_plus_xy_over_yy_type;
+// typedef typename boost::units::divide_typeof_helper<
+// xy_minus_xy_type,yy_type>::type xy_minus_xy_over_yy_type;
+//
+// BOOST_STATIC_ASSERT((boost::is_same<xy_plus_xy_over_yy_type,
+// xy_minus_xy_over_yy_type>::value == true));
+//
+// return complex<xy_plus_xy_over_yy_type>(
+// (x.real()*y.real()+x.imag()*y.imag())/
+// (y.real()*y.real()+y.imag()*y.imag()),
+// (x.imag()*y.real()-x.real()*y.imag())/
+// (y.real()*y.real()+y.imag()*y.imag()));
+}
+
+template<class Y>
+complex<Y>
+pow(const complex<Y>& x,const Y& y)
+{
+ std::complex<Y> tmp(x.real(),x.imag());
+
+ tmp = std::pow(tmp,y);
+
+ return complex<Y>(tmp.real(),tmp.imag());
+}
+
+template<class Y>
+std::ostream& operator<<(std::ostream& os,const complex<Y>& val)
+{
+ os << val.real() << " + " << val.imag() << " i";
+
+ return os;
+}
+
+/// specialize power typeof helper for complex<Y>
+template<class Y,long N,long D>
+struct power_typeof_helper<complex<Y>,static_rational<N,D> >
+{
+ typedef complex<
+ typename power_typeof_helper<Y,static_rational<N,D> >::type
+ > type;
+
+ static type value(const complex<Y>& x)
+ {
+ const static_rational<N,D> rat;
+
+ const Y m = Y(rat.numerator())/Y(rat.denominator());
+
+ return boost::units::pow(x,m);
+ }
+};
+
+/// specialize root typeof helper for complex<Y>
+template<class Y,long N,long D>
+struct root_typeof_helper<complex<Y>,static_rational<N,D> >
+{
+ typedef complex<
+ typename root_typeof_helper<Y,static_rational<N,D> >::type
+ > type;
+
+ static type value(const complex<Y>& x)
+ {
+ const static_rational<N,D> rat;
+
+ const Y m = Y(rat.denominator())/Y(rat.numerator());
+
+ return boost::units::pow(x,m);
+ }
+};
+
+/// specialize power typeof helper for complex<quantity<Unit,Y> >
+template<class Y,class Unit,long N,long D>
+struct power_typeof_helper<complex<quantity<Unit,Y> >,static_rational<N,D> >
+{
+ typedef typename
+ power_typeof_helper<Y,static_rational<N,D> >::type value_type;
+ typedef typename
+ power_typeof_helper<Unit,static_rational<N,D> >::type unit_type;
+ typedef quantity<unit_type,value_type> quantity_type;
+ typedef complex<quantity_type> type;
+
+ static type value(const complex<quantity<Unit,Y> >& x)
+ {
+ const complex<value_type> tmp =
+ pow<static_rational<N,D> >(complex<Y>(x.real().value(),
+ x.imag().value()));
+
+ return type(quantity_type::from_value(tmp.real()),
+ quantity_type::from_value(tmp.imag()));
+ }
+};
+
+/// specialize root typeof helper for complex<quantity<Unit,Y> >
+template<class Y,class Unit,long N,long D>
+struct root_typeof_helper<complex<quantity<Unit,Y> >,static_rational<N,D> >
+{
+ typedef typename
+ root_typeof_helper<Y,static_rational<N,D> >::type value_type;
+ typedef typename
+ root_typeof_helper<Unit,static_rational<N,D> >::type unit_type;
+ typedef quantity<unit_type,value_type> quantity_type;
+ typedef complex<quantity_type> type;
+
+ static type value(const complex<quantity<Unit,Y> >& x)
+ {
+ const complex<value_type> tmp =
+ root<static_rational<N,D> >(complex<Y>(x.real().value(),
+ x.imag().value()));
+
+ return type(quantity_type::from_value(tmp.real()),
+ quantity_type::from_value(tmp.imag()));
+ }
+};
+
+} // namespace units
+
+} // namespace boost
+//]
+
+int main(void)
+{
+ using namespace boost::units;
+ using namespace boost::units::test;
+
+ {
+ //[complex_snippet_1
+ typedef quantity<length,complex<double> > length_dimension;
+
+ const length_dimension L(complex<double>(2.0,1.0)*meters);
+ //]
+
+ std::cout << "+L = " << +L << std::endl
+ << "-L = " << -L << std::endl
+ << "L+L = " << L+L << std::endl
+ << "L-L = " << L-L << std::endl
+ << "L*L = " << L*L << std::endl
+ << "L/L = " << L/L << std::endl
+ << "L^3 = " << pow<3>(L) << std::endl
+ << "L^(3/2) = " << pow< static_rational<3,2> >(L) << std::endl
+ << "3vL = " << root<3>(L) << std::endl
+ << "(3/2)vL = " << root< static_rational<3,2> >(L) << std::endl
+ << std::endl;
+ }
+
+ {
+ //[complex_snippet_2
+ typedef complex<quantity<length> > length_dimension;
+
+ const length_dimension L(2.0*meters,1.0*meters);
+ //]
+
+ std::cout << "+L = " << +L << std::endl
+ << "-L = " << -L << std::endl
+ << "L+L = " << L+L << std::endl
+ << "L-L = " << L-L << std::endl
+ << "L*L = " << L*L << std::endl
+ << "L/L = " << L/L << std::endl
+ << "L^3 = " << pow<3>(L) << std::endl
+ << "L^(3/2) = " << pow< static_rational<3,2> >(L) << std::endl
+ << "3vL = " << root<3>(L) << std::endl
+ << "(3/2)vL = " << root< static_rational<3,2> >(L) << std::endl
+ << std::endl;
+ }
+
+ return 0;
+}
diff --git a/src/boost/libs/units/example/composite_output.cpp b/src/boost/libs/units/example/composite_output.cpp
new file mode 100644
index 000000000..022ea4e60
--- /dev/null
+++ b/src/boost/libs/units/example/composite_output.cpp
@@ -0,0 +1,116 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2008 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)
+
+/**
+\file
+
+\brief composite_output.cpp
+
+\details An example of textual representations of units.
+
+Output:
+@verbatim
+
+//[conversion_output_output
+2 dyn
+2 dyn
+2 dyne
+cm g s^-1
+centimeter gram second^-1
+dyn
+dyne
+n
+nano
+n
+nano
+F
+farad
+1 F
+1 farad
+nF
+nanofarad
+1 nF
+1 nanofarad
+n(cm g s^-1)
+nano(centimeter gram second^-1)
+//]
+
+@endverbatim
+**/
+#include <boost/units/quantity.hpp>
+#include <boost/units/systems/cgs.hpp>
+#include <boost/units/io.hpp>
+#include <boost/units/scale.hpp>
+
+#include <boost/units/detail/utility.hpp>
+
+#include <boost/units/systems/si/capacitance.hpp>
+#include <boost/units/systems/si/io.hpp>
+#include <boost/units/systems/si/prefixes.hpp>
+
+#include <iostream>
+#include <sstream>
+
+namespace boost {
+
+namespace units {
+
+//[composite_output_snippet_1
+
+std::string name_string(const cgs::force&)
+{
+ return "dyne";
+}
+
+std::string symbol_string(const cgs::force&)
+{
+ return "dyn";
+}
+
+//]
+
+}
+
+}
+
+int main()
+{
+ using namespace boost::units;
+ using boost::units::cgs::centimeter;
+ using boost::units::cgs::gram;
+ using boost::units::cgs::second;
+ using boost::units::cgs::dyne;
+
+ //[composite_output_snippet_2]
+ std::cout << 2.0 * dyne << std::endl
+ << symbol_format << 2.0 * dyne << std::endl
+ << name_format << 2.0 * dyne << std::endl
+ << symbol_format << gram*centimeter/second << std::endl
+ << name_format << gram*centimeter/second << std::endl
+ << symbol_format << gram*centimeter/(second*second) << std::endl
+ << name_format << gram*centimeter/(second*second) << std::endl
+ << symbol_string(scale<10,static_rational<-9> >()) << std::endl
+ << name_string(scale<10,static_rational<-9> >()) << std::endl
+ << symbol_format << si::nano << std::endl
+ << name_format << si::nano << std::endl
+ << symbol_format << si::farad << std::endl
+ << name_format << si::farad << std::endl
+ << symbol_format << 1.0*si::farad << std::endl
+ << name_format << 1.0*si::farad << std::endl
+ << symbol_format << si::farad*si::nano << std::endl
+ << name_format << si::farad*si::nano << std::endl
+ << symbol_format << 1.0*si::farad*si::nano << std::endl
+ << name_format << 1.0*si::farad*si::nano << std::endl
+ << symbol_format << si::nano*gram*centimeter/second << std::endl
+ << name_format << si::nano*gram*centimeter/second << std::endl;
+ //]
+
+ return 0;
+}
diff --git a/src/boost/libs/units/example/conversion.cpp b/src/boost/libs/units/example/conversion.cpp
new file mode 100644
index 000000000..0299dfdcf
--- /dev/null
+++ b/src/boost/libs/units/example/conversion.cpp
@@ -0,0 +1,124 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2008 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)
+
+/**
+\file
+
+\brief conversion.cpp
+
+\details
+Test explicit and implicit unit conversion.
+
+Output:
+@verbatim
+
+//[conversion_output_1
+L1 = 2 m
+L2 = 2 m
+L3 = 2 m
+L4 = 200 cm
+L5 = 5 m
+L6 = 4 m
+L7 = 200 cm
+//]
+
+//[conversion_output_2
+volume (m^3) = 1 m^3
+volume (cm^3) = 1e+06 cm^3
+volume (m^3) = 1 m^3
+
+energy (joules) = 1 J
+energy (ergs) = 1e+07 erg
+energy (joules) = 1 J
+
+velocity (2 m/s) = 2 m s^-1
+velocity (2 cm/s) = 0.02 m s^-1
+//]
+
+@endverbatim
+**/
+
+#include <iostream>
+
+#include <boost/units/io.hpp>
+#include <boost/units/pow.hpp>
+#include <boost/units/systems/cgs.hpp>
+#include <boost/units/systems/cgs/io.hpp>
+#include <boost/units/systems/si.hpp>
+#include <boost/units/systems/si/io.hpp>
+
+using namespace boost::units;
+
+int main()
+{
+ // test quantity_cast
+ {
+ // implicit value_type conversions
+ //[conversion_snippet_1
+ quantity<si::length> L1 = quantity<si::length,int>(int(2.5)*si::meters);
+ quantity<si::length,int> L2(quantity<si::length,double>(2.5*si::meters));
+ //]
+
+ //[conversion_snippet_3
+ quantity<si::length,int> L3 = static_cast<quantity<si::length,int> >(L1);
+ //]
+
+ //[conversion_snippet_4
+ quantity<cgs::length> L4 = static_cast<quantity<cgs::length> >(L1);
+ //]
+
+ quantity<si::length,int> L5(4*si::meters),
+ L6(5*si::meters);
+ quantity<cgs::length> L7(L1);
+
+ swap(L5,L6);
+
+ std::cout << "L1 = " << L1 << std::endl
+ << "L2 = " << L2 << std::endl
+ << "L3 = " << L3 << std::endl
+ << "L4 = " << L4 << std::endl
+ << "L5 = " << L5 << std::endl
+ << "L6 = " << L6 << std::endl
+ << "L7 = " << L7 << std::endl
+ << std::endl;
+ }
+
+ // test explicit unit system conversion
+ {
+ //[conversion_snippet_5
+ quantity<si::volume> vs(1.0*pow<3>(si::meter));
+ quantity<cgs::volume> vc(vs);
+ quantity<si::volume> vs2(vc);
+
+ quantity<si::energy> es(1.0*si::joule);
+ quantity<cgs::energy> ec(es);
+ quantity<si::energy> es2(ec);
+
+ quantity<si::velocity> v1 = 2.0*si::meters/si::second,
+ v2(2.0*cgs::centimeters/cgs::second);
+ //]
+
+ std::cout << "volume (m^3) = " << vs << std::endl
+ << "volume (cm^3) = " << vc << std::endl
+ << "volume (m^3) = " << vs2 << std::endl
+ << std::endl;
+
+ std::cout << "energy (joules) = " << es << std::endl
+ << "energy (ergs) = " << ec << std::endl
+ << "energy (joules) = " << es2 << std::endl
+ << std::endl;
+
+ std::cout << "velocity (2 m/s) = " << v1 << std::endl
+ << "velocity (2 cm/s) = " << v2 << std::endl
+ << std::endl;
+ }
+
+ return 0;
+}
diff --git a/src/boost/libs/units/example/conversion_factor.cpp b/src/boost/libs/units/example/conversion_factor.cpp
new file mode 100644
index 000000000..4401e4774
--- /dev/null
+++ b/src/boost/libs/units/example/conversion_factor.cpp
@@ -0,0 +1,76 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2008 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)
+
+/**
+\file
+
+\brief conversion_factor.cpp
+
+\details An example of using conversion_factor.
+
+Output:
+@verbatim
+
+//[conversion_factor_output
+1e-005
+100
+1e-005
+100
+0.01
+//]
+
+@endverbatim
+**/
+
+#include <iostream>
+
+#include <boost/units/cmath.hpp>
+#include <boost/units/io.hpp>
+#include <boost/units/quantity.hpp>
+#include <boost/units/systems/cgs/acceleration.hpp>
+#include <boost/units/systems/si/acceleration.hpp>
+#include <boost/units/systems/si/force.hpp>
+#include <boost/units/systems/cgs/force.hpp>
+#include <boost/units/systems/si/mass.hpp>
+#include <boost/units/systems/cgs/mass.hpp>
+#include <boost/units/systems/si/momentum.hpp>
+#include <boost/units/systems/cgs/momentum.hpp>
+
+int main()
+{
+ using namespace boost;
+ using namespace boost::units;
+
+ //[conversion_factor_snippet_1
+
+ double dyne_to_newton =
+ conversion_factor(cgs::dyne,si::newton);
+ std::cout << dyne_to_newton << std::endl;
+
+ double force_over_mass_conversion =
+ conversion_factor(si::newton/si::kilogram,cgs::dyne/cgs::gram);
+ std::cout << force_over_mass_conversion << std::endl;
+
+ double momentum_conversion =
+ conversion_factor(cgs::momentum(),si::momentum());
+ std::cout << momentum_conversion << std::endl;
+
+ double momentum_over_mass_conversion =
+ conversion_factor(si::momentum()/si::mass(),cgs::momentum()/cgs::gram);
+ std::cout << momentum_over_mass_conversion << std::endl;
+
+ double acceleration_conversion =
+ conversion_factor(cgs::gal,si::meter_per_second_squared);
+ std::cout << acceleration_conversion << std::endl;
+
+ //]
+
+ return 0;
+}
diff --git a/src/boost/libs/units/example/dimension.cpp b/src/boost/libs/units/example/dimension.cpp
new file mode 100644
index 000000000..7f7ffb6bc
--- /dev/null
+++ b/src/boost/libs/units/example/dimension.cpp
@@ -0,0 +1,117 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2008 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)
+
+/**
+\file
+
+\brief dimension.cpp
+
+\details
+Test dimension list manipulation.
+
+Output:
+@verbatim
+
+//[dimension_output
+length_dimension = list<dim<length_base_dimension, static_rational<1l, 1l> >, dimensionless_type>
+mass_dimension = list<dim<mass_base_dimension, static_rational<1l, 1l> >, dimensionless_type>
+time_dimension = list<dim<time_base_dimension, static_rational<1l, 1l> >, dimensionless_type>
+energy_dimension = list<dim<length_base_dimension, static_rational<2l, 1l> >, list<dim<mass_base_dimension, static_rational<1l, 1l> >, list<dim<time_base_dimension, static_rational<-2l, 1l> >, dimensionless_type> > >
+LM_type = list<dim<length_base_dimension, static_rational<1l, 1l> >, list<dim<mass_base_dimension, static_rational<1l, 1l> >, dimensionless_type> >
+L_T_type = list<dim<length_base_dimension, static_rational<1l, 1l> >, list<dim<time_base_dimension, static_rational<-1l, 1l> >, dimensionless_type> >
+V_type = list<dim<length_base_dimension, static_rational<1l, 1l> >, list<dim<time_base_dimension, static_rational<-1l, 1l> >, dimensionless_type> >
+//]
+
+@endverbatim
+**/
+
+#include <boost/type_traits/is_same.hpp>
+#include <boost/mpl/assert.hpp>
+
+#include <iostream>
+
+#include <boost/units/detail/utility.hpp>
+
+#include "test_system.hpp"
+
+namespace mpl = boost::mpl;
+
+int main(void)
+{
+ using namespace boost::units;
+
+ BOOST_MPL_ASSERT((boost::is_same<
+ length_dimension,
+ mpl::push_front<
+ dimensionless_type,
+ dim<length_base_dimension, static_rational<1L, 1L> >
+ >::type
+ >));
+ BOOST_MPL_ASSERT((boost::is_same<
+ mass_dimension,
+ mpl::push_front<
+ dimensionless_type,
+ dim<mass_base_dimension, static_rational<1L, 1L> >
+ >::type
+ >));
+ BOOST_MPL_ASSERT((boost::is_same<energy_dimension,
+ mpl::push_front<
+ mpl::push_front<
+ mpl::push_front<
+ dimensionless_type,
+ dim<time_base_dimension, static_rational<-2L, 1L> > >::type,
+ dim<mass_base_dimension, static_rational<1L, 1L> > >::type,
+ dim<length_base_dimension, static_rational<2L, 1L> > >::type>));
+
+ std::cout << "length_dimension = "
+ << simplify_typename(length_dimension()) << std::endl
+ << "mass_dimension = "
+ << simplify_typename(mass_dimension()) << std::endl
+ << "time_dimension = "
+ << simplify_typename(time_dimension()) << std::endl
+ << "energy_dimension = "
+ << simplify_typename(energy_dimension()) << std::endl;
+
+ //[dimension_snippet_1
+ typedef mpl::times<length_dimension,mass_dimension>::type LM_type;
+ typedef mpl::divides<length_dimension,time_dimension>::type L_T_type;
+ typedef static_root<
+ mpl::divides<energy_dimension,mass_dimension>::type,
+ static_rational<2>
+ >::type V_type;
+ //]
+
+ BOOST_MPL_ASSERT((boost::is_same<LM_type,
+ mpl::push_front<
+ mpl::push_front<
+ dimensionless_type,
+ dim<mass_base_dimension, static_rational<1L, 1L> > >::type,
+ dim<length_base_dimension, static_rational<1L, 1L> > >::type>));
+
+ BOOST_MPL_ASSERT((boost::is_same<L_T_type,
+ mpl::push_front<
+ mpl::push_front<
+ dimensionless_type,
+ dim<time_base_dimension, static_rational<-1L, 1L> > >::type,
+ dim<length_base_dimension, static_rational<1L, 1L> > >::type>));
+
+ BOOST_MPL_ASSERT((boost::is_same<V_type,
+ mpl::push_front<
+ mpl::push_front<
+ dimensionless_type,
+ dim<time_base_dimension, static_rational<-1L, 1L> > >::type,
+ dim<length_base_dimension, static_rational<1L, 1L> > >::type>));
+
+ std::cout << "LM_type = " << simplify_typename(LM_type()) << std::endl
+ << "L_T_type = " << simplify_typename(L_T_type()) << std::endl
+ << "V_type = " << simplify_typename(V_type()) << std::endl;
+
+ return 0;
+}
diff --git a/src/boost/libs/units/example/heterogeneous_unit.cpp b/src/boost/libs/units/example/heterogeneous_unit.cpp
new file mode 100644
index 000000000..7a4f11234
--- /dev/null
+++ b/src/boost/libs/units/example/heterogeneous_unit.cpp
@@ -0,0 +1,87 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2008 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)
+
+/**
+\file
+
+\brief heterogeneous_unit.cpp
+
+\details
+Test heterogeneous units and quantities.
+
+Output:
+@verbatim
+
+//[heterogeneous_unit_output_1
+1.5 m
+1 g
+1.5 m g
+1.5 m g^-1
+
+1 N
+1 kg s^-2
+
+1 cm kg s^-2
+1 cm m^-1 kg s^-2
+//]
+
+//[heterogeneous_unit_output_2
+1.5 cm m
+0.015 m^2
+//]
+
+@endverbatim
+**/
+
+#define MCS_USE_DEMANGLING
+//#define MCS_USE_BOOST_REGEX_DEMANGLING
+
+#include <iostream>
+
+#include <boost/units/io.hpp>
+#include <boost/units/pow.hpp>
+#include <boost/units/detail/utility.hpp>
+#include <boost/units/systems/cgs.hpp>
+#include <boost/units/systems/si.hpp>
+#include <boost/units/systems/si/io.hpp>
+
+using namespace boost::units;
+
+int main()
+{
+ //[heterogeneous_unit_snippet_1
+ quantity<si::length> L(1.5*si::meter);
+ quantity<cgs::mass> M(1.0*cgs::gram);
+
+ std::cout << L << std::endl
+ << M << std::endl
+ << L*M << std::endl
+ << L/M << std::endl
+ << std::endl;
+
+ std::cout << 1.0*si::meter*si::kilogram/pow<2>(si::second) << std::endl
+ << 1.0*si::meter*si::kilogram/pow<2>(si::second)/si::meter
+ << std::endl << std::endl;
+
+ std::cout << 1.0*cgs::centimeter*si::kilogram/pow<2>(si::second) << std::endl
+ << 1.0*cgs::centimeter*si::kilogram/pow<2>(si::second)/si::meter
+ << std::endl << std::endl;
+ //]
+
+ //[heterogeneous_unit_snippet_2
+ quantity<si::area> A(1.5*si::meter*cgs::centimeter);
+
+ std::cout << 1.5*si::meter*cgs::centimeter << std::endl
+ << A << std::endl
+ << std::endl;
+ //]
+
+ return 0;
+}
diff --git a/src/boost/libs/units/example/information.cpp b/src/boost/libs/units/example/information.cpp
new file mode 100644
index 000000000..21ae3f917
--- /dev/null
+++ b/src/boost/libs/units/example/information.cpp
@@ -0,0 +1,100 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2014 Erik Erlandson
+//
+// 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)
+
+//#include <boost/units/systems/information.hpp>
+
+/**
+\file
+
+\brief information.cpp
+
+\details
+Demonstrate information unit system.
+
+Output:
+@verbatim
+bytes= 1.25e+08 B
+bits= 8e+06 b
+nats= 4605.17 nat
+1024 bytes in a kibi-byte
+8.38861e+06 bits in a mebi-byte
+0.000434294 hartleys in a milli-nat
+entropy in bits= 1 b
+entropy in nats= 0.693147 nat
+entropy in hartleys= 0.30103 Hart
+entropy in shannons= 1 Sh
+entropy in bytes= 0.125 B
+@endverbatim
+**/
+
+#include <cmath>
+#include <iostream>
+using std::cout;
+using std::endl;
+using std::log;
+
+#include <boost/units/quantity.hpp>
+#include <boost/units/io.hpp>
+#include <boost/units/conversion.hpp>
+namespace bu = boost::units;
+using bu::quantity;
+using bu::conversion_factor;
+
+// SI prefixes
+#include <boost/units/systems/si/prefixes.hpp>
+namespace si = boost::units::si;
+
+// information unit system
+#include <boost/units/systems/information.hpp>
+using namespace bu::information;
+
+// Define a function for the entropy of a bernoulli trial.
+// The formula is computed using natural log, so the units are in nats.
+// The user provides the desired return unit, the only restriction being that it
+// must be a unit of information. Conversion to the requested return unit is
+// accomplished automatically by the boost::units library.
+template <typename Sys>
+constexpr
+quantity<bu::unit<bu::information_dimension, Sys> >
+bernoulli_entropy(double p, const bu::unit<bu::information_dimension, Sys>&) {
+ typedef bu::unit<bu::information_dimension, Sys> requested_unit;
+ return quantity<requested_unit>((-(p*log(p) + (1-p)*log(1-p)))*nats);
+}
+
+int main(int argc, char** argv) {
+ // a quantity of information (default in units of bytes)
+ quantity<info> nbytes(1 * si::giga * bit);
+ cout << "bytes= " << nbytes << endl;
+
+ // a quantity of information, stored as bits
+ quantity<hu::bit::info> nbits(1 * si::mega * byte);
+ cout << "bits= " << nbits << endl;
+
+ // a quantity of information, stored as nats
+ quantity<hu::nat::info> nnats(2 * si::kilo * hartleys);
+ cout << "nats= " << nnats << endl;
+
+ // how many bytes are in a kibi-byte?
+ cout << conversion_factor(kibi * byte, byte) << " bytes in a kibi-byte" << endl;
+
+ // how many bits are in a mebi-byte?
+ cout << conversion_factor(mebi * byte, bit) << " bits in a mebi-byte" << endl;
+
+ // how many hartleys are in a milli-nat?
+ cout << conversion_factor(si::milli * nat, hartley) << " hartleys in a milli-nat" << endl;
+
+ // compute the entropy of a fair coin flip, in various units of information:
+ cout << "entropy in bits= " << bernoulli_entropy(0.5, bits) << endl;
+ cout << "entropy in nats= " << bernoulli_entropy(0.5, nats) << endl;
+ cout << "entropy in hartleys= " << bernoulli_entropy(0.5, hartleys) << endl;
+ cout << "entropy in shannons= " << bernoulli_entropy(0.5, shannons) << endl;
+ cout << "entropy in bytes= " << bernoulli_entropy(0.5, bytes) << endl;
+
+ return 0;
+}
diff --git a/src/boost/libs/units/example/kitchen_sink.cpp b/src/boost/libs/units/example/kitchen_sink.cpp
new file mode 100644
index 000000000..ece126bc2
--- /dev/null
+++ b/src/boost/libs/units/example/kitchen_sink.cpp
@@ -0,0 +1,542 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2008 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)
+
+/**
+\file
+
+\brief kitchen_sink.cpp
+
+\details
+More extensive quantity tests.
+
+Output:
+@verbatim
+
+//[kitchen_sink_output_1
+S1 : 2
+X1 : 2
+X2 : (4/3)
+U1 : N
+U2 : J
+Q1 : 1 N
+Q2 : 2 J
+//]
+
+//[kitchen_sink_output_2
+U1*S1 : 2 N
+S1*U1 : 2 N
+U1/S1 : 0.5 N
+S1/U1 : 2 m^-1 kg^-1 s^2
+//]
+
+//[kitchen_sink_output_3
+U1+U1 : N
+U1-U1 : N
+U1*U1 : m^2 kg^2 s^-4
+U1/U1 : dimensionless
+U1*U2 : m^3 kg^2 s^-4
+U1/U2 : m^-1
+U1^X : m^2 kg^2 s^-4
+X1vU1 : m^(1/2) kg^(1/2) s^-1
+U1^X2 : m^(4/3) kg^(4/3) s^(-8/3)
+X2vU1 : m^(3/4) kg^(3/4) s^(-3/2)
+//]
+
+//[kitchen_sink_output_4
+Q1*S1 : 2 N
+S1*Q1 : 2 N
+Q1/S1 : 0.5 N
+S1/Q1 : 2 m^-1 kg^-1 s^2
+//]
+
+//[kitchen_sink_output_5
+U1*Q1 : 1 m^2 kg^2 s^-4
+Q1*U1 : 1 m^2 kg^2 s^-4
+U1/Q1 : 1 dimensionless
+Q1/U1 : 1 dimensionless
+//]
+
+//[kitchen_sink_output_6
++Q1 : 1 N
+-Q1 : -1 N
+Q1+Q1 : 2 N
+Q1-Q1 : 0 N
+Q1*Q1 : 1 m^2 kg^2 s^-4
+Q1/Q1 : 1 dimensionless
+Q1*Q2 : 2 m^3 kg^2 s^-4
+Q1/Q2 : 0.5 m^-1
+Q1^X1 : 1 m^2 kg^2 s^-4
+X1vQ1 : 1 m^(1/2) kg^(1/2) s^-1
+Q1^X2 : 1 m^(4/3) kg^(4/3) s^(-8/3)
+X2vQ1 : 1 m^(3/4) kg^(3/4) s^(-3/2)
+//]
+
+//[kitchen_sink_output_7
+l1 == l2 false
+l1 != l2 true
+l1 <= l2 true
+l1 < l2 true
+l1 >= l2 false
+l1 > l2 false
+//]
+
+dimless = 1
+
+//[kitchen_sink_output_8
+v1 = 2 m s^-1
+//]
+
+//[kitchen_sink_output_9
+F = 1 N
+dx = 1 m
+E = 1 J
+//]
+
+//[kitchen_sink_output_10
+r = 5e-07 m
+P = 101325 Pa
+V = 5.23599e-19 m^3
+T = 310 K
+n = 2.05835e-17 mol
+R = 8.314472 m^2 kg s^-2 K^-1 mol^-1 (rel. unc. = 1.8e-06)
+//]
+
+//[kitchen_sink_output_11
+theta = 0.375 rd
+sin(theta) = 0.366273 dimensionless
+asin(sin(theta)) = 0.375 rd
+//]
+
+//[kitchen_sink_output_12
+V = (12.5,0) V
+I = (3,4) A
+Z = (1.5,-2) Ohm
+I*Z = (12.5,0) V
+//]
+
+//[kitchen_sink_output_13
+x+y-w = 0.48(+/-0.632772) m
+w*x = 9.04(+/-0.904885) m^2
+x/y = 0.666667(+/-0.149071) dimensionless
+//]
+
+//[kitchen_sink_output_14
+w*y^2/(u*x)^2 = 10.17(+/-3.52328) m^-1
+w/(u*x)^(1/2) = 3.19612(+/-0.160431) dimensionless
+//]
+
+//[kitchen_sink_output_15
+I*w = m^2 kg s^-1 rad^-1
+I*w/L = dimensionless
+I*w^2 = J
+//]
+
+//[kitchen_sink_output_16
+1 F
+1 kat
+1 S
+1 C
+1 V
+1 J
+1 N
+1 Hz
+1 lx
+1 H
+1 lm
+1 Wb
+1 T
+1 W
+1 Pa
+1 Ohm
+//]
+
+//[kitchen_sink_output_18
+1 farad
+1 katal
+1 siemen
+1 coulomb
+1 volt
+1 joule
+1 newton
+1 hertz
+1 lux
+1 henry
+1 lumen
+1 weber
+1 tesla
+1 watt
+1 pascal
+1 ohm
+//]
+
+@endverbatim
+**/
+
+#include <cmath>
+#include <complex>
+#include <iostream>
+
+#include <boost/typeof/std/complex.hpp>
+
+#include <boost/units/cmath.hpp>
+#include <boost/units/io.hpp>
+#include <boost/units/systems/si.hpp>
+#include <boost/units/systems/si/codata/physico-chemical_constants.hpp>
+#include <boost/units/systems/si/io.hpp>
+
+#include "measurement.hpp"
+
+namespace boost {
+
+namespace units {
+
+//[kitchen_sink_function_snippet_3
+/// the physical definition of work - computed for an arbitrary unit system
+template<class System,class Y>
+constexpr
+quantity<unit<energy_dimension,System>,Y>
+work(quantity<unit<force_dimension,System>,Y> F,
+ quantity<unit<length_dimension,System>,Y> dx)
+{
+ return F*dx;
+}
+//]
+
+//[kitchen_sink_function_snippet_4
+/// the ideal gas law in si units
+template<class Y>
+constexpr
+quantity<si::amount,Y>
+idealGasLaw(const quantity<si::pressure,Y>& P,
+ const quantity<si::volume,Y>& V,
+ const quantity<si::temperature,Y>& T)
+{
+ using namespace boost::units::si;
+
+ using namespace constants::codata;
+ return (P*V/(R*T));
+}
+//]
+
+} // namespace units
+
+} // namespace boost
+
+int main()
+{
+ using namespace boost::units;
+ using namespace boost::units::si;
+
+ {
+ //[kitchen_sink_snippet_1
+ /// scalar
+ const double s1 = 2;
+
+ const long x1 = 2;
+ const static_rational<4,3> x2;
+
+ /// define some units
+ force u1 = newton;
+ energy u2 = joule;
+
+ /// define some quantities
+ quantity<force> q1(1.0*u1);
+ quantity<energy> q2(2.0*u2);
+ //]
+
+ /// check scalar, unit, and quantity io
+ std::cout << "S1 : " << s1 << std::endl
+ << "X1 : " << x1 << std::endl
+ << "X2 : " << x2 << std::endl
+ << "U1 : " << u1 << std::endl
+ << "U2 : " << u2 << std::endl
+ << "Q1 : " << q1 << std::endl
+ << "Q2 : " << q2 << std::endl
+ << std::endl;
+
+ /// check scalar-unit algebra
+ std::cout //<< "U1+S1 : " << u1+s1 << std::endl // illegal
+ //<< "S1+U1 : " << s1+u1 << std::endl // illegal
+ //<< "U1-S1 : " << u1-s1 << std::endl // illegal
+ //<< "S1-U1 : " << s1-u1 << std::endl // illegal
+ << "U1*S1 : " << u1*s1 << std::endl
+ << "S1*U1 : " << s1*u1 << std::endl
+ << "U1/S1 : " << u1/s1 << std::endl
+ << "S1/U1 : " << s1/u1 << std::endl
+ << std::endl;
+
+ /// check unit-unit algebra
+ std::cout << "U1+U1 : " << u1+u1 << std::endl
+ << "U1-U1 : " << u1-u1 << std::endl
+ << "U1*U1 : " << u1*u1 << std::endl
+ << "U1/U1 : " << u1/u1 << std::endl
+ //<< "U1+U2 : " << u1+u2 << std::endl // illegal
+ //<< "U1-U2 : " << u1-u2 << std::endl // illegal
+ << "U1*U2 : " << u1*u2 << std::endl
+ << "U1/U2 : " << u1/u2 << std::endl
+ << "U1^X : " << pow<2>(u1) << std::endl
+ << "X1vU1 : " << root<2>(u1) << std::endl
+ << "U1^X2 : " << pow<static_rational<4,3> >(u1) << std::endl
+ << "X2vU1 : " << root<static_rational<4,3> >(u1) << std::endl
+ << std::endl;
+
+ /// check scalar-quantity algebra
+ std::cout //<< "Q1+S1 : " << q1+s1 << std::endl // illegal
+ //<< "S1+Q1 : " << s1+q1 << std::endl // illegal
+ //<< "Q1-S1 : " << q1-s1 << std::endl // illegal
+ //<< "S1-Q1 : " << s1-q1 << std::endl // illegal
+ << "Q1*S1 : " << q1*s1 << std::endl
+ << "S1*Q1 : " << s1*q1 << std::endl
+ << "Q1/S1 : " << q1/s1 << std::endl
+ << "S1/Q1 : " << s1/q1 << std::endl
+ << std::endl;
+
+ /// check unit-quantity algebra
+ std::cout //<< "U1+Q1 : " << u1+q1 << std::endl // illegal
+ //<< "Q1+U1 : " << q1+u1 << std::endl // illegal
+ //<< "U1-Q1 : " << u1-q1 << std::endl // illegal
+ //<< "Q1-U1 : " << q1-u1 << std::endl // illegal
+ << "U1*Q1 : " << u1*q1 << std::endl
+ << "Q1*U1 : " << q1*u1 << std::endl
+ << "U1/Q1 : " << u1/q1 << std::endl
+ << "Q1/U1 : " << q1/u1 << std::endl
+ << std::endl;
+
+ /// check quantity-quantity algebra
+ std::cout << "+Q1 : " << +q1 << std::endl
+ << "-Q1 : " << -q1 << std::endl
+ << "Q1+Q1 : " << q1+q1 << std::endl
+ << "Q1-Q1 : " << q1-q1 << std::endl
+ << "Q1*Q1 : " << q1*q1 << std::endl
+ << "Q1/Q1 : " << q1/q1 << std::endl
+ //<< "Q1+Q2 : " << q1+q2 << std::endl // illegal
+ //<< "Q1-Q2 : " << q1-q2 << std::endl // illegal
+ << "Q1*Q2 : " << q1*q2 << std::endl
+ << "Q1/Q2 : " << q1/q2 << std::endl
+ << "Q1^X1 : " << pow<2>(q1) << std::endl
+ << "X1vQ1 : " << root<2>(q1) << std::endl
+ << "Q1^X2 : " << pow<static_rational<4,3> >(q1) << std::endl
+ << "X2vQ1 : " << root<static_rational<4,3> >(q1) << std::endl
+ << std::endl;
+
+ //[kitchen_sink_snippet_2
+ /// check comparison tests
+ quantity<length> l1(1.0*meter),
+ l2(2.0*meters);
+ //]
+
+ std::cout << std::boolalpha
+ << "l1 == l2" << "\t" << (l1 == l2) << std::endl
+ << "l1 != l2" << "\t" << (l1 != l2) << std::endl
+ << "l1 <= l2" << "\t" << (l1 <= l2) << std::endl
+ << "l1 < l2 " << "\t" << (l1 < l2) << std::endl
+ << "l1 >= l2" << "\t" << (l1 >= l2) << std::endl
+ << "l1 > l2 " << "\t" << (l1 > l2) << std::endl
+ << std::endl;
+
+ //[kitchen_sink_snippet_3
+ /// check implicit unit conversion from dimensionless to value_type
+ const double dimless = (q1/q1);
+ //]
+
+ std::cout << "dimless = " << dimless << std::endl
+ << std::endl;
+
+ quantity<velocity> v1 = 2.0*meters/second;
+
+ std::cout << "v1 = " << v1 << std::endl
+ << std::endl;
+
+ //[kitchen_sink_snippet_4
+ /// test calcuation of work
+ quantity<force> F(1.0*newton);
+ quantity<length> dx(1.0*meter);
+ quantity<energy> E(work(F,dx));
+ //]
+
+ std::cout << "F = " << F << std::endl
+ << "dx = " << dx << std::endl
+ << "E = " << E << std::endl
+ << std::endl;
+
+ {
+ //[kitchen_sink_snippet_5
+ /// test ideal gas law
+ quantity<temperature> T = (273.+37.)*kelvin;
+ quantity<pressure> P = 1.01325e5*pascals;
+ quantity<length> r = 0.5e-6*meters;
+ quantity<volume> V = (4.0/3.0)*3.141592*pow<3>(r);
+ quantity<amount> n(idealGasLaw(P,V,T));
+ //]
+
+ std::cout << "r = " << r << std::endl
+ << "P = " << P << std::endl
+ << "V = " << V << std::endl
+ << "T = " << T << std::endl
+ << "n = " << n << std::endl
+ #if BOOST_UNITS_HAS_TYPEOF
+ << "R = " << constants::codata::R << std::endl
+ #else
+ << "no typeof" << std::endl
+ #endif // BOOST_UNITS_HAS_TYPEOF
+ << std::endl;
+ }
+
+ //[kitchen_sink_snippet_6
+ /// test trig stuff
+ quantity<plane_angle> theta = 0.375*radians;
+ quantity<dimensionless> sin_theta = sin(theta);
+ quantity<plane_angle> thetap = asin(sin_theta);
+ //]
+
+ std::cout << "theta = " << theta << std::endl
+ << "sin(theta) = " << sin_theta << std::endl
+ << "asin(sin(theta)) = " << thetap << std::endl
+ << std::endl;
+
+ /// test implicit conversion of dimensionless to value
+ double tmp = sin_theta;
+
+ tmp = sin_theta;
+
+ /// test implicit conversion from value to dimensionless
+ quantity<dimensionless> tmpp = tmp;
+
+ tmpp = tmp;
+
+ /// check complex quantities
+ typedef std::complex<double> complex_type;
+
+ //[kitchen_sink_snippet_7
+ quantity<electric_potential,complex_type> v = complex_type(12.5,0.0)*volts;
+ quantity<current,complex_type> i = complex_type(3.0,4.0)*amperes;
+ quantity<resistance,complex_type> z = complex_type(1.5,-2.0)*ohms;
+ //]
+
+ std::cout << "V = " << v << std::endl
+ << "I = " << i << std::endl
+ << "Z = " << z << std::endl
+ << "I*Z = " << i*z << std::endl
+ << std::endl;
+
+ /// check quantities using user-defined type encapsulating error propagation
+
+ //[kitchen_sink_snippet_8
+ quantity<length,measurement<double> >
+ u(measurement<double>(1.0,0.0)*meters),
+ w(measurement<double>(4.52,0.02)*meters),
+ x(measurement<double>(2.0,0.2)*meters),
+ y(measurement<double>(3.0,0.6)*meters);
+ //]
+
+ std::cout << "x+y-w = " << x+y-w << std::endl
+ << "w*x = " << w*x << std::endl
+ << "x/y = " << x/y << std::endl
+ << "w*y^2/(u*x)^2 = " << w*y*y/pow<2>(u*x) << std::endl
+ << "w/(u*x)^(1/2) = " << w/pow< static_rational<1,2> >(u*x)
+ << std::endl << std::endl;
+ }
+
+ /// check moment of inertia/angular momentum/rotational energy
+
+ //[kitchen_sink_snippet_9
+ std::cout << symbol_format
+ << "I*w = " << moment_of_inertia()*angular_velocity() << std::endl
+ << "I*w/L = " << moment_of_inertia()*angular_velocity()/angular_momentum() << std::endl
+ << "I*w^2 = " << moment_of_inertia()*pow<2>(angular_velocity()) << std::endl
+ << std::endl;
+ //]
+
+ //[kitchen_sink_snippet_10
+// std::cout << typename_format
+// << quantity<capacitance>(1.0*farad) << std::endl
+// << quantity<catalytic_activity>(1.0*katal) << std::endl
+// << quantity<conductance>(1.0*siemen) << std::endl
+// << quantity<electric_charge>(1.0*coulomb) << std::endl
+// << quantity<electric_potential>(1.0*volt) << std::endl
+// << quantity<energy>(1.0*joule) << std::endl
+// << quantity<force>(1.0*newton) << std::endl
+// << quantity<frequency>(1.0*hertz) << std::endl
+// << quantity<illuminance>(1.0*lux) << std::endl
+// << quantity<inductance>(1.0*henry) << std::endl
+// << quantity<luminous_flux>(1.0*lumen) << std::endl
+// << quantity<magnetic_flux>(1.0*weber) << std::endl
+// << quantity<magnetic_flux_density>(1.0*tesla) << std::endl
+// << quantity<power>(1.0*watt) << std::endl
+// << quantity<pressure>(1.0*pascals) << std::endl
+// << quantity<resistance>(1.0*ohm) << std::endl
+// << std::endl;
+ //]
+
+ //[kitchen_sink_snippet_11
+// std::cout << raw_format
+// << quantity<capacitance>(1.0*farad) << std::endl
+// << quantity<catalytic_activity>(1.0*katal) << std::endl
+// << quantity<conductance>(1.0*siemen) << std::endl
+// << quantity<electric_charge>(1.0*coulomb) << std::endl
+// << quantity<electric_potential>(1.0*volt) << std::endl
+// << quantity<energy>(1.0*joule) << std::endl
+// << quantity<force>(1.0*newton) << std::endl
+// << quantity<frequency>(1.0*hertz) << std::endl
+// << quantity<illuminance>(1.0*lux) << std::endl
+// << quantity<inductance>(1.0*henry) << std::endl
+// << quantity<luminous_flux>(1.0*lumen) << std::endl
+// << quantity<magnetic_flux>(1.0*weber) << std::endl
+// << quantity<magnetic_flux_density>(1.0*tesla) << std::endl
+// << quantity<power>(1.0*watt) << std::endl
+// << quantity<pressure>(1.0*pascals) << std::endl
+// << quantity<resistance>(1.0*ohm) << std::endl
+// << std::endl;
+ //]
+
+ //[kitchen_sink_snippet_12
+ std::cout << symbol_format
+ << quantity<capacitance>(1.0*farad) << std::endl
+ << quantity<catalytic_activity>(1.0*katal) << std::endl
+ << quantity<conductance>(1.0*siemen) << std::endl
+ << quantity<electric_charge>(1.0*coulomb) << std::endl
+ << quantity<electric_potential>(1.0*volt) << std::endl
+ << quantity<energy>(1.0*joule) << std::endl
+ << quantity<force>(1.0*newton) << std::endl
+ << quantity<frequency>(1.0*hertz) << std::endl
+ << quantity<illuminance>(1.0*lux) << std::endl
+ << quantity<inductance>(1.0*henry) << std::endl
+ << quantity<luminous_flux>(1.0*lumen) << std::endl
+ << quantity<magnetic_flux>(1.0*weber) << std::endl
+ << quantity<magnetic_flux_density>(1.0*tesla) << std::endl
+ << quantity<power>(1.0*watt) << std::endl
+ << quantity<pressure>(1.0*pascals) << std::endl
+ << quantity<resistance>(1.0*ohm) << std::endl
+ << std::endl;
+ //]
+
+ //[kitchen_sink_snippet_13
+ std::cout << name_format
+ << quantity<capacitance>(1.0*farad) << std::endl
+ << quantity<catalytic_activity>(1.0*katal) << std::endl
+ << quantity<conductance>(1.0*siemen) << std::endl
+ << quantity<electric_charge>(1.0*coulomb) << std::endl
+ << quantity<electric_potential>(1.0*volt) << std::endl
+ << quantity<energy>(1.0*joule) << std::endl
+ << quantity<force>(1.0*newton) << std::endl
+ << quantity<frequency>(1.0*hertz) << std::endl
+ << quantity<illuminance>(1.0*lux) << std::endl
+ << quantity<inductance>(1.0*henry) << std::endl
+ << quantity<luminous_flux>(1.0*lumen) << std::endl
+ << quantity<magnetic_flux>(1.0*weber) << std::endl
+ << quantity<magnetic_flux_density>(1.0*tesla) << std::endl
+ << quantity<power>(1.0*watt) << std::endl
+ << quantity<pressure>(1.0*pascals) << std::endl
+ << quantity<resistance>(1.0*ohm) << std::endl
+ << std::endl;
+ //]
+
+ return 0;
+}
diff --git a/src/boost/libs/units/example/lambda.cpp b/src/boost/libs/units/example/lambda.cpp
new file mode 100644
index 000000000..0fbac9160
--- /dev/null
+++ b/src/boost/libs/units/example/lambda.cpp
@@ -0,0 +1,157 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2008 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)
+
+// $Id: lambda.cpp 27 2008-06-16 14:50:58Z maehne $
+
+////////////////////////////////////////////////////////////////////////
+///
+/// \file lambda.cpp
+///
+/// \brief Example demonstrating the usage of Boost.Units' quantity,
+/// unit, and absolute types in functors created with the
+/// Boost.Lambda library and stored in Boost.Function objects.
+///
+/// \author Torsten Maehne
+/// \date 2008-06-04
+///
+/// A mechanical, electrical, geometrical, and thermal example
+/// demonstrate how to use Boost.Units' quantity, unit, and absolute
+/// types in lambda expressions. The resulting functors can be stored
+/// in boost::function objects. It is also shown how to work around a
+/// limitation of Boost.Lambda's bind() to help it to find the correct
+/// overloaded function by specifying its signature with a
+/// static_cast.
+///
+////////////////////////////////////////////////////////////////////////
+
+#include <iostream>
+#include <boost/function.hpp>
+#include <boost/units/io.hpp>
+#include <boost/units/cmath.hpp>
+#include <boost/units/pow.hpp>
+#include <boost/units/systems/si.hpp>
+#include <boost/units/absolute.hpp>
+
+// Include boost/units/lambda.hpp instead of boost/lambda/lambda.hpp
+// for a convenient usage of Boost.Units' quantity, unit, and absolute
+// types in lambda expressions. The header augments Boost.Lambda's
+// return type detuction system to recognize the new types so that not
+// for each arithmetic operation the return type needs to be
+// explicitely specified.
+#include <boost/units/lambda.hpp>
+
+#include <boost/lambda/bind.hpp>
+
+static const double pi = 3.14159265358979323846;
+
+//[lambda_snippet_1
+
+int main(int argc, char **argv) {
+
+ using namespace std;
+ namespace bl = boost::lambda;
+ namespace bu = boost::units;
+ namespace si = boost::units::si;
+
+
+ ////////////////////////////////////////////////////////////////////////
+ // Mechanical example: linear accelerated movement
+ ////////////////////////////////////////////////////////////////////////
+
+ // Initial condition variables for acceleration, speed, and displacement
+ bu::quantity<si::acceleration> a = 2.0 * si::meters_per_second_squared;
+ bu::quantity<si::velocity> v = 1.0 * si::meters_per_second;
+ bu::quantity<si::length> s0 = 0.5 * si::meter;
+
+ // Displacement over time
+ boost::function<bu::quantity<si::length> (bu::quantity<si::time>) >
+ s = 0.5 * bl::var(a) * bl::_1 * bl::_1
+ + bl::var(v) * bl::_1
+ + bl::var(s0);
+
+ cout << "Linear accelerated movement:" << endl
+ << "a = " << a << ", v = " << v << ", s0 = " << s0 << endl
+ << "s(1.0 * si::second) = " << s(1.0 * si::second) << endl
+ << endl;
+
+ // Change initial conditions
+ a = 1.0 * si::meters_per_second_squared;
+ v = 2.0 * si::meters_per_second;
+ s0 = -1.5 * si::meter;
+
+ cout << "a = " << a << ", v = " << v << ", s0 = " << s0 << endl
+ << "s(1.0 * si::second) = " << s(1.0 * si::second) << endl
+ << endl;
+
+
+ ////////////////////////////////////////////////////////////////////////
+ // Electrical example: oscillating current
+ ////////////////////////////////////////////////////////////////////////
+
+ // Constants for the current amplitude, frequency, and offset current
+ const bu::quantity<si::current> iamp = 1.5 * si::ampere;
+ const bu::quantity<si::frequency> f = 1.0e3 * si::hertz;
+ const bu::quantity<si::current> i0 = 0.5 * si::ampere;
+
+ // The invocation of the sin function needs to be postponed using
+ // bind to specify the oscillation function. A lengthy static_cast
+ // to the function pointer referencing boost::units::sin() is needed
+ // to avoid an "unresolved overloaded function type" error.
+ boost::function<bu::quantity<si::current> (bu::quantity<si::time>) >
+ i = iamp
+ * bl::bind(static_cast<bu::dimensionless_quantity<si::system, double>::type (*)(const bu::quantity<si::plane_angle>&)>(bu::sin),
+ 2.0 * pi * si::radian * f * bl::_1)
+ + i0;
+
+ cout << "Oscillating current:" << endl
+ << "iamp = " << iamp << ", f = " << f << ", i0 = " << i0 << endl
+ << "i(1.25e-3 * si::second) = " << i(1.25e-3 * si::second) << endl
+ << endl;
+
+
+ ////////////////////////////////////////////////////////////////////////
+ // Geometric example: area calculation for a square
+ ////////////////////////////////////////////////////////////////////////
+
+ // Length constant
+ const bu::quantity<si::length> l = 1.5 * si::meter;
+
+ // Again an ugly static_cast is needed to bind pow<2> to the first
+ // function argument.
+ boost::function<bu::quantity<si::area> (bu::quantity<si::length>) >
+ A = bl::bind(static_cast<bu::quantity<si::area> (*)(const bu::quantity<si::length>&)>(bu::pow<2>),
+ bl::_1);
+
+ cout << "Area of a square:" << endl
+ << "A(" << l <<") = " << A(l) << endl << endl;
+
+
+ ////////////////////////////////////////////////////////////////////////
+ // Thermal example: temperature difference of two absolute temperatures
+ ////////////////////////////////////////////////////////////////////////
+
+ // Absolute temperature constants
+ const bu::quantity<bu::absolute<si::temperature> >
+ Tref = 273.15 * bu::absolute<si::temperature>();
+ const bu::quantity<bu::absolute<si::temperature> >
+ Tamb = 300.00 * bu::absolute<si::temperature>();
+
+ boost::function<bu::quantity<si::temperature> (bu::quantity<bu::absolute<si::temperature> >,
+ bu::quantity<bu::absolute<si::temperature> >)>
+ dT = bl::_2 - bl::_1;
+
+ cout << "Temperature difference of two absolute temperatures:" << endl
+ << "dT(" << Tref << ", " << Tamb << ") = " << dT(Tref, Tamb) << endl
+ << endl;
+
+
+ return 0;
+}
+//]
diff --git a/src/boost/libs/units/example/measurement.hpp b/src/boost/libs/units/example/measurement.hpp
new file mode 100644
index 000000000..72063023b
--- /dev/null
+++ b/src/boost/libs/units/example/measurement.hpp
@@ -0,0 +1,344 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2008 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)
+
+#ifndef BOOST_UNITS_MEASUREMENT_HPP
+#define BOOST_UNITS_MEASUREMENT_HPP
+
+#include <cmath>
+#include <cstdlib>
+#include <iomanip>
+#include <iostream>
+
+#include <boost/io/ios_state.hpp>
+#include <boost/units/static_rational.hpp>
+
+namespace boost {
+
+namespace units {
+
+namespace sqr_namespace /**/ {
+
+template<class Y>
+constexpr
+Y sqr(Y val)
+{ return val*val; }
+
+} // namespace
+
+using sqr_namespace::sqr;
+
+template<class Y>
+class measurement
+{
+ public:
+ typedef measurement<Y> this_type;
+ typedef Y value_type;
+
+ constexpr measurement(const value_type& val = value_type(),
+ const value_type& err = value_type()) :
+ value_(val),
+ uncertainty_(std::abs(err))
+ { }
+
+ constexpr measurement(const this_type& source) :
+ value_(source.value_),
+ uncertainty_(source.uncertainty_)
+ { }
+
+ //~measurement() { }
+
+ constexpr this_type& operator=(const this_type& source)
+ {
+ if (this == &source) return *this;
+
+ value_ = source.value_;
+ uncertainty_ = source.uncertainty_;
+
+ return *this;
+ }
+
+ constexpr operator value_type() const { return value_; }
+
+ constexpr value_type value() const { return value_; }
+ constexpr value_type uncertainty() const { return uncertainty_; }
+ constexpr value_type lower_bound() const { return value_-uncertainty_; }
+ constexpr value_type upper_bound() const { return value_+uncertainty_; }
+
+ constexpr this_type& operator+=(const value_type& val)
+ {
+ value_ += val;
+ return *this;
+ }
+
+ constexpr this_type& operator-=(const value_type& val)
+ {
+ value_ -= val;
+ return *this;
+ }
+
+ constexpr this_type& operator*=(const value_type& val)
+ {
+ value_ *= val;
+ uncertainty_ *= val;
+ return *this;
+ }
+
+ constexpr this_type& operator/=(const value_type& val)
+ {
+ value_ /= val;
+ uncertainty_ /= val;
+ return *this;
+ }
+
+ constexpr this_type& operator+=(const this_type& /*source*/);
+ constexpr this_type& operator-=(const this_type& /*source*/);
+ constexpr this_type& operator*=(const this_type& /*source*/);
+ constexpr this_type& operator/=(const this_type& /*source*/);
+
+ private:
+ value_type value_,
+ uncertainty_;
+};
+
+}
+
+}
+
+#if BOOST_UNITS_HAS_BOOST_TYPEOF
+
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::units::measurement, 1)
+
+#endif
+
+namespace boost {
+
+namespace units {
+
+template<class Y>
+inline
+constexpr
+measurement<Y>&
+measurement<Y>::operator+=(const this_type& source)
+{
+ uncertainty_ = std::sqrt(sqr(uncertainty_)+sqr(source.uncertainty_));
+ value_ += source.value_;
+
+ return *this;
+}
+
+template<class Y>
+inline
+constexpr
+measurement<Y>&
+measurement<Y>::operator-=(const this_type& source)
+{
+ uncertainty_ = std::sqrt(sqr(uncertainty_)+sqr(source.uncertainty_));
+ value_ -= source.value_;
+
+ return *this;
+}
+
+template<class Y>
+inline
+constexpr
+measurement<Y>&
+measurement<Y>::operator*=(const this_type& source)
+{
+ uncertainty_ = (value_*source.value_)*
+ std::sqrt(sqr(uncertainty_/value_)+
+ sqr(source.uncertainty_/source.value_));
+ value_ *= source.value_;
+
+ return *this;
+}
+
+template<class Y>
+inline
+constexpr
+measurement<Y>&
+measurement<Y>::operator/=(const this_type& source)
+{
+ uncertainty_ = (value_/source.value_)*
+ std::sqrt(sqr(uncertainty_/value_)+
+ sqr(source.uncertainty_/source.value_));
+ value_ /= source.value_;
+
+ return *this;
+}
+
+// value_type op measurement
+template<class Y>
+inline
+constexpr
+measurement<Y>
+operator+(Y lhs,const measurement<Y>& rhs)
+{
+ return (measurement<Y>(lhs,Y(0))+=rhs);
+}
+
+template<class Y>
+inline
+constexpr
+measurement<Y>
+operator-(Y lhs,const measurement<Y>& rhs)
+{
+ return (measurement<Y>(lhs,Y(0))-=rhs);
+}
+
+template<class Y>
+inline
+constexpr
+measurement<Y>
+operator*(Y lhs,const measurement<Y>& rhs)
+{
+ return (measurement<Y>(lhs,Y(0))*=rhs);
+}
+
+template<class Y>
+inline
+constexpr
+measurement<Y>
+operator/(Y lhs,const measurement<Y>& rhs)
+{
+ return (measurement<Y>(lhs,Y(0))/=rhs);
+}
+
+// measurement op value_type
+template<class Y>
+inline
+constexpr
+measurement<Y>
+operator+(const measurement<Y>& lhs,Y rhs)
+{
+ return (measurement<Y>(lhs)+=measurement<Y>(rhs,Y(0)));
+}
+
+template<class Y>
+inline
+constexpr
+measurement<Y>
+operator-(const measurement<Y>& lhs,Y rhs)
+{
+ return (measurement<Y>(lhs)-=measurement<Y>(rhs,Y(0)));
+}
+
+template<class Y>
+inline
+constexpr
+measurement<Y>
+operator*(const measurement<Y>& lhs,Y rhs)
+{
+ return (measurement<Y>(lhs)*=measurement<Y>(rhs,Y(0)));
+}
+
+template<class Y>
+inline
+constexpr
+measurement<Y>
+operator/(const measurement<Y>& lhs,Y rhs)
+{
+ return (measurement<Y>(lhs)/=measurement<Y>(rhs,Y(0)));
+}
+
+// measurement op measurement
+template<class Y>
+inline
+constexpr
+measurement<Y>
+operator+(const measurement<Y>& lhs,const measurement<Y>& rhs)
+{
+ return (measurement<Y>(lhs)+=rhs);
+}
+
+template<class Y>
+inline
+constexpr
+measurement<Y>
+operator-(const measurement<Y>& lhs,const measurement<Y>& rhs)
+{
+ return (measurement<Y>(lhs)-=rhs);
+}
+
+template<class Y>
+inline
+constexpr
+measurement<Y>
+operator*(const measurement<Y>& lhs,const measurement<Y>& rhs)
+{
+ return (measurement<Y>(lhs)*=rhs);
+}
+
+template<class Y>
+inline
+constexpr
+measurement<Y>
+operator/(const measurement<Y>& lhs,const measurement<Y>& rhs)
+{
+ return (measurement<Y>(lhs)/=rhs);
+}
+
+/// specialize power typeof helper
+template<class Y,long N,long D>
+struct power_typeof_helper<measurement<Y>,static_rational<N,D> >
+{
+ typedef measurement<
+ typename power_typeof_helper<Y,static_rational<N,D> >::type
+ > type;
+
+ static constexpr type value(const measurement<Y>& x)
+ {
+ const static_rational<N,D> rat;
+
+ const Y m = Y(rat.numerator())/Y(rat.denominator()),
+ newval = std::pow(x.value(),m),
+ err = newval*std::sqrt(std::pow(m*x.uncertainty()/x.value(),2));
+
+ return type(newval,err);
+ }
+};
+
+/// specialize root typeof helper
+template<class Y,long N,long D>
+struct root_typeof_helper<measurement<Y>,static_rational<N,D> >
+{
+ typedef measurement<
+ typename root_typeof_helper<Y,static_rational<N,D> >::type
+ > type;
+
+ static constexpr type value(const measurement<Y>& x)
+ {
+ const static_rational<N,D> rat;
+
+ const Y m = Y(rat.denominator())/Y(rat.numerator()),
+ newval = std::pow(x.value(),m),
+ err = newval*std::sqrt(std::pow(m*x.uncertainty()/x.value(),2));
+
+ return type(newval,err);
+ }
+};
+
+// stream output
+template<class Y>
+inline
+std::ostream& operator<<(std::ostream& os,const measurement<Y>& val)
+{
+ boost::io::ios_precision_saver precision_saver(os);
+ boost::io::ios_flags_saver flags_saver(os);
+
+ os << val.value() << "(+/-" << val.uncertainty() << ")";
+
+ return os;
+}
+
+} // namespace units
+
+} // namespace boost
+
+#endif // BOOST_UNITS_MEASUREMENT_HPP
diff --git a/src/boost/libs/units/example/non_base_dimension.cpp b/src/boost/libs/units/example/non_base_dimension.cpp
new file mode 100644
index 000000000..4476a34e1
--- /dev/null
+++ b/src/boost/libs/units/example/non_base_dimension.cpp
@@ -0,0 +1,78 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2007-2008 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)
+
+/**
+\file
+
+\brief non_base_dimension.cpp
+
+\details
+Another example of user-defined units with conversions.
+
+Output:
+@verbatim
+
+//[non_base_dimension_output
+//]
+
+@endverbatim
+**/
+
+#include <iostream>
+
+#include <boost/units/io.hpp>
+#include <boost/units/conversion.hpp>
+#include <boost/units/unit.hpp>
+#include <boost/units/quantity.hpp>
+#include <boost/units/physical_dimensions.hpp>
+#include <boost/units/base_unit.hpp>
+#include <boost/units/make_system.hpp>
+
+namespace boost {
+
+namespace units {
+
+//[non_base_dimension_snippet_1
+
+struct imperial_gallon_tag :
+ base_unit<imperial_gallon_tag, volume_dimension, 1> { };
+
+typedef make_system<imperial_gallon_tag>::type imperial;
+
+typedef unit<volume_dimension,imperial> imperial_gallon;
+
+struct us_gallon_tag : base_unit<us_gallon_tag, volume_dimension, 2> { };
+
+typedef make_system<us_gallon_tag>::type us;
+
+typedef unit<volume_dimension,us> us_gallon;
+
+//]
+
+} // namespace units
+
+} // namespace boost
+
+BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::imperial_gallon_tag,
+ boost::units::us_gallon_tag,
+ double, 1.2009499255);
+
+using namespace boost::units;
+
+int main(void)
+{
+ quantity<imperial_gallon> ig1(1.0*imperial_gallon());
+ quantity<us_gallon> ug1(1.0*us_gallon());
+
+ quantity<imperial_gallon> ig2(ug1);
+ quantity<us_gallon> ug2(ig1);
+
+ return 0;
+}
diff --git a/src/boost/libs/units/example/performance.cpp b/src/boost/libs/units/example/performance.cpp
new file mode 100644
index 000000000..fd2abe10d
--- /dev/null
+++ b/src/boost/libs/units/example/performance.cpp
@@ -0,0 +1,395 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2008 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)
+
+/**
+\file
+
+\brief performance.cpp
+
+\details
+Test runtime performance.
+
+Output:
+@verbatim
+
+multiplying ublas::matrix<double>(1000, 1000) : 25.03 seconds
+multiplying ublas::matrix<quantity>(1000, 1000) : 24.49 seconds
+tiled_matrix_multiply<double>(1000, 1000) : 1.12 seconds
+tiled_matrix_multiply<quantity>(1000, 1000) : 1.16 seconds
+solving y' = 1 - x + 4 * y with double: 1.97 seconds
+solving y' = 1 - x + 4 * y with quantity: 1.84 seconds
+
+@endverbatim
+**/
+
+#define _SCL_SECURE_NO_WARNINGS
+
+#include <cstdlib>
+#include <ctime>
+#include <algorithm>
+#include <iostream>
+#include <iomanip>
+
+#include <boost/config.hpp>
+#include <boost/timer.hpp>
+#include <boost/utility/result_of.hpp>
+
+#ifdef BOOST_MSVC
+#pragma warning(push)
+#pragma warning(disable:4267; disable:4127; disable:4244; disable:4100)
+#endif
+
+#include <boost/numeric/ublas/matrix.hpp>
+
+#ifdef BOOST_MSVC
+#pragma warning(pop)
+#endif
+
+#include <boost/units/quantity.hpp>
+#include <boost/units/systems/si.hpp>
+#include <boost/units/cmath.hpp>
+#include <boost/units/io.hpp>
+
+enum {
+ tile_block_size = 24
+};
+
+template<class T0, class T1, class Out>
+void tiled_multiply_carray_inner(T0* first,
+ T1* second,
+ Out* out,
+ int totalwidth,
+ int width2,
+ int height1,
+ int common) {
+ for(int j = 0; j < height1; ++j) {
+ for(int i = 0; i < width2; ++i) {
+ Out value = out[j * totalwidth + i];
+ for(int k = 0; k < common; ++k) {
+ value += first[k + totalwidth * j] * second[k * totalwidth + i];
+ }
+ out[j * totalwidth + i] = value;
+ }
+ }
+}
+
+template<class T0, class T1, class Out>
+void tiled_multiply_carray_outer(T0* first,
+ T1* second,
+ Out* out,
+ int width2,
+ int height1,
+ int common) {
+ std::fill_n(out, width2 * height1, Out());
+ int j = 0;
+ for(; j < height1 - tile_block_size; j += tile_block_size) {
+ int i = 0;
+ for(; i < width2 - tile_block_size; i += tile_block_size) {
+ int k = 0;
+ for(; k < common - tile_block_size; k += tile_block_size) {
+ tiled_multiply_carray_inner(
+ &first[k + width2 * j],
+ &second[k * width2 + i],
+ &out[j * width2 + i],
+ width2,
+ tile_block_size,
+ tile_block_size,
+ tile_block_size);
+ }
+ tiled_multiply_carray_inner(
+ &first[k + width2 * j],
+ &second[k * width2 + i],
+ &out[j * width2 + i],
+ width2,
+ tile_block_size,
+ tile_block_size,
+ common - k);
+ }
+ int k = 0;
+ for(; k < common - tile_block_size; k += tile_block_size) {
+ tiled_multiply_carray_inner(
+ &first[k + width2 * j],
+ &second[k * width2 + i],
+ &out[j * width2 + i],
+ width2, width2 - i,
+ tile_block_size,
+ tile_block_size);
+ }
+ tiled_multiply_carray_inner(
+ &first[k + width2 * j],
+ &second[k * width2 + i],
+ &out[j * width2 + i],
+ width2, width2 - i,
+ tile_block_size,
+ common - k);
+ }
+ int i = 0;
+ for(; i < width2 - tile_block_size; i += tile_block_size) {
+ int k = 0;
+ for(; k < common - tile_block_size; k += tile_block_size) {
+ tiled_multiply_carray_inner(
+ &first[k + width2 * j],
+ &second[k * width2 + i],
+ &out[j * width2 + i],
+ width2,
+ tile_block_size,
+ height1 - j,
+ tile_block_size);
+ }
+ tiled_multiply_carray_inner(
+ &first[k + width2 * j],
+ &second[k * width2 + i],
+ &out[j * width2 + i],
+ width2,
+ tile_block_size,
+ height1 - j,
+ common - k);
+ }
+ int k = 0;
+ for(; k < common - tile_block_size; k += tile_block_size) {
+ tiled_multiply_carray_inner(
+ &first[k + width2 * j],
+ &second[k * width2 + i],
+ &out[j * width2 + i],
+ width2,
+ width2 - i,
+ height1 - j,
+ tile_block_size);
+ }
+ tiled_multiply_carray_inner(
+ &first[k + width2 * j],
+ &second[k * width2 + i],
+ &out[j * width2 + i],
+ width2,
+ width2 - i,
+ height1 - j,
+ common - k);
+}
+
+enum { max_value = 1000};
+
+template<class F, class T, class N, class R>
+BOOST_CXX14_CONSTEXPR
+R solve_differential_equation(F f, T lower, T upper, N steps, R start) {
+ typedef typename F::template result<T, R>::type f_result;
+ T h = (upper - lower) / (1.0*steps);
+ for(N i = N(); i < steps; ++i) {
+ R y = start;
+ T x = lower + h * (1.0*i);
+ f_result k1 = f(x, y);
+ f_result k2 = f(x + h / 2.0, y + h * k1 / 2.0);
+ f_result k3 = f(x + h / 2.0, y + h * k2 / 2.0);
+ f_result k4 = f(x + h, y + h * k3);
+ start = y + h * (k1 + 2.0 * k2 + 2.0 * k3 + k4) / 6.0;
+ }
+ return(start);
+}
+
+using namespace boost::units;
+
+//y' = 1 - x + 4 * y
+struct f {
+ template<class Arg1, class Arg2> struct result;
+
+ BOOST_CONSTEXPR double operator()(const double& x, const double& y) const {
+ return(1.0 - x + 4.0 * y);
+ }
+
+ boost::units::quantity<boost::units::si::velocity>
+ BOOST_CONSTEXPR operator()(const quantity<si::time>& x,
+ const quantity<si::length>& y) const {
+ using namespace boost::units;
+ using namespace si;
+ return(1.0 * meters / second -
+ x * meters / pow<2>(seconds) +
+ 4.0 * y / seconds );
+ }
+};
+
+template<>
+struct f::result<double,double> {
+ typedef double type;
+};
+
+template<>
+struct f::result<quantity<si::time>, quantity<si::length> > {
+ typedef quantity<si::velocity> type;
+};
+
+
+
+//y' = 1 - x + 4 * y
+//y' - 4 * y = 1 - x
+//e^(-4 * x) * (dy - 4 * y * dx) = e^(-4 * x) * (1 - x) * dx
+//d/dx(y * e ^ (-4 * x)) = e ^ (-4 * x) (1 - x) * dx
+
+//d/dx(y * e ^ (-4 * x)) = e ^ (-4 * x) * dx - x * e ^ (-4 * x) * dx
+//d/dx(y * e ^ (-4 * x)) = d/dx((-3/16 + 1/4 * x) * e ^ (-4 * x))
+//y * e ^ (-4 * x) = (-3/16 + 1/4 * x) * e ^ (-4 * x) + C
+//y = (-3/16 + 1/4 * x) + C/e ^ (-4 * x)
+//y = 1/4 * x - 3/16 + C * e ^ (4 * x)
+
+//y(0) = 1
+//1 = - 3/16 + C
+//C = 19/16
+//y(x) = 1/4 * x - 3/16 + 19/16 * e ^ (4 * x)
+
+
+
+int main() {
+ boost::numeric::ublas::matrix<double> ublas_result;
+ {
+ boost::numeric::ublas::matrix<double> m1(max_value, max_value);
+ boost::numeric::ublas::matrix<double> m2(max_value, max_value);
+ std::srand(1492);
+ for(int i = 0; i < max_value; ++i) {
+ for(int j = 0; j < max_value; ++j) {
+ m1(i,j) = std::rand();
+ m2(i,j) = std::rand();
+ }
+ }
+ std::cout << "multiplying ublas::matrix<double>("
+ << max_value << ", " << max_value << ") : ";
+ boost::timer timer;
+ ublas_result = (prod(m1, m2));
+ std::cout << timer.elapsed() << " seconds" << std::endl;
+ }
+ typedef boost::numeric::ublas::matrix<
+ boost::units::quantity<boost::units::si::dimensionless>
+ > matrix_type;
+ matrix_type ublas_resultq;
+ {
+ matrix_type m1(max_value, max_value);
+ matrix_type m2(max_value, max_value);
+ std::srand(1492);
+ for(int i = 0; i < max_value; ++i) {
+ for(int j = 0; j < max_value; ++j) {
+ m1(i,j) = std::rand();
+ m2(i,j) = std::rand();
+ }
+ }
+ std::cout << "multiplying ublas::matrix<quantity>("
+ << max_value << ", " << max_value << ") : ";
+ boost::timer timer;
+ ublas_resultq = (prod(m1, m2));
+ std::cout << timer.elapsed() << " seconds" << std::endl;
+ }
+ std::vector<double> cresult(max_value * max_value);
+ {
+ std::vector<double> m1(max_value * max_value);
+ std::vector<double> m2(max_value * max_value);
+ std::srand(1492);
+ for(int i = 0; i < max_value * max_value; ++i) {
+ m1[i] = std::rand();
+ m2[i] = std::rand();
+ }
+ std::cout << "tiled_matrix_multiply<double>("
+ << max_value << ", " << max_value << ") : ";
+ boost::timer timer;
+ tiled_multiply_carray_outer(
+ &m1[0],
+ &m2[0],
+ &cresult[0],
+ max_value,
+ max_value,
+ max_value);
+ std::cout << timer.elapsed() << " seconds" << std::endl;
+ }
+ std::vector<
+ boost::units::quantity<boost::units::si::energy>
+ > cresultq(max_value * max_value);
+ {
+ std::vector<
+ boost::units::quantity<boost::units::si::force>
+ > m1(max_value * max_value);
+ std::vector<
+ boost::units::quantity<boost::units::si::length>
+ > m2(max_value * max_value);
+ std::srand(1492);
+ for(int i = 0; i < max_value * max_value; ++i) {
+ m1[i] = std::rand() * boost::units::si::newtons;
+ m2[i] = std::rand() * boost::units::si::meters;
+ }
+ std::cout << "tiled_matrix_multiply<quantity>("
+ << max_value << ", " << max_value << ") : ";
+ boost::timer timer;
+ tiled_multiply_carray_outer(
+ &m1[0],
+ &m2[0],
+ &cresultq[0],
+ max_value,
+ max_value,
+ max_value);
+ std::cout << timer.elapsed() << " seconds" << std::endl;
+ }
+ for(int i = 0; i < max_value; ++i) {
+ for(int j = 0; j < max_value; ++j) {
+ const double diff =
+ std::abs(ublas_result(i,j) - cresult[i * max_value + j]);
+ if(diff > ublas_result(i,j) /1e14) {
+ std::cout << std::setprecision(15) << "Uh Oh. ublas_result("
+ << i << "," << j << ") = " << ublas_result(i,j)
+ << std::endl
+ << "cresult[" << i << " * " << max_value << " + "
+ << j << "] = " << cresult[i * max_value + j]
+ << std::endl;
+ return(EXIT_FAILURE);
+ }
+ }
+ }
+ {
+ std::vector<double> values(1000);
+ std::cout << "solving y' = 1 - x + 4 * y with double: ";
+ boost::timer timer;
+ for(int i = 0; i < 1000; ++i) {
+ const double x = .1 * i;
+ values[i] = solve_differential_equation(f(), 0.0, x, i * 100, 1.0);
+ }
+ std::cout << timer.elapsed() << " seconds" << std::endl;
+ for(int i = 0; i < 1000; ++i) {
+ const double x = .1 * i;
+ const double value = 1.0/4.0 * x - 3.0/16.0 + 19.0/16.0 * std::exp(4 * x);
+ if(std::abs(values[i] - value) > value / 1e9) {
+ std::cout << std::setprecision(15) << "i = : " << i
+ << ", value = " << value << " approx = " << values[i]
+ << std::endl;
+ return(EXIT_FAILURE);
+ }
+ }
+ }
+ {
+ using namespace boost::units;
+ using namespace si;
+ std::vector<quantity<length> > values(1000);
+ std::cout << "solving y' = 1 - x + 4 * y with quantity: ";
+ boost::timer timer;
+ for(int i = 0; i < 1000; ++i) {
+ const quantity<si::time> x = .1 * i * seconds;
+ values[i] = solve_differential_equation(
+ f(),
+ 0.0 * seconds,
+ x,
+ i * 100,
+ 1.0 * meters);
+ }
+ std::cout << timer.elapsed() << " seconds" << std::endl;
+ for(int i = 0; i < 1000; ++i) {
+ const double x = .1 * i;
+ const quantity<si::length> value =
+ (1.0/4.0 * x - 3.0/16.0 + 19.0/16.0 * std::exp(4 * x)) * meters;
+ if(abs(values[i] - value) > value / 1e9) {
+ std::cout << std::setprecision(15) << "i = : " << i
+ << ", value = " << value << " approx = "
+ << values[i] << std::endl;
+ return(EXIT_FAILURE);
+ }
+ }
+ }
+}
diff --git a/src/boost/libs/units/example/quantity.cpp b/src/boost/libs/units/example/quantity.cpp
new file mode 100644
index 000000000..e3d3f18ac
--- /dev/null
+++ b/src/boost/libs/units/example/quantity.cpp
@@ -0,0 +1,128 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2008 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)
+
+/**
+\file
+
+\brief quantity.cpp
+
+\details
+Test quantity algebra.
+
+Output:
+@verbatim
+
+//[quantity_output_double
+L = 2 m
+L+L = 4 m
+L-L = 0 m
+L*L = 4 m^2
+L/L = 1 dimensionless
+L*meter = 2 m^2
+kilograms*(L/seconds)*(L/seconds) = 4 m^2 kg s^-2
+kilograms*(L/seconds)^2 = 4 m^2 kg s^-2
+L^3 = 8 m^3
+L^(3/2) = 2.82843 m^(3/2)
+2vL = 1.41421 m^(1/2)
+(3/2)vL = 1.5874 m^(2/3)
+//]
+
+//[quantity_output_complex
+L = (3,4) m
+L+L = (6,8) m
+L-L = (0,0) m
+L*L = (-7,24) m^2
+L/L = (1,0) dimensionless
+L*meter = (3,4) m^2
+kilograms*(L/seconds)*(L/seconds) = (-7,24) m^2 kg s^-2
+kilograms*(L/seconds)^2 = (-7,24) m^2 kg s^-2
+L^3 = (-117,44) m^3
+L^(3/2) = (2,11) m^(3/2)
+2vL = (2,1) m^(1/2)
+(3/2)vL = (2.38285,1.69466) m^(2/3)
+//]
+
+@endverbatim
+**/
+
+#include <complex>
+#include <iostream>
+
+#include <boost/mpl/list.hpp>
+
+#include <boost/typeof/std/complex.hpp>
+
+#include <boost/units/pow.hpp>
+#include <boost/units/quantity.hpp>
+#include <boost/units/io.hpp>
+
+#include "test_system.hpp"
+
+int main(void)
+{
+ using namespace boost::units;
+ using namespace boost::units::test;
+
+ {
+ //[quantity_snippet_1
+ quantity<length> L = 2.0*meters; // quantity of length
+ quantity<energy> E = kilograms*pow<2>(L/seconds); // quantity of energy
+ //]
+
+ std::cout << "L = " << L << std::endl
+ << "L+L = " << L+L << std::endl
+ << "L-L = " << L-L << std::endl
+ << "L*L = " << L*L << std::endl
+ << "L/L = " << L/L << std::endl
+ << "L*meter = " << L*meter << std::endl
+ << "kilograms*(L/seconds)*(L/seconds) = "
+ << kilograms*(L/seconds)*(L/seconds) << std::endl
+ << "kilograms*(L/seconds)^2 = "
+ << kilograms*pow<2>(L/seconds) << std::endl
+ << "L^3 = "
+ << pow<3>(L) << std::endl
+ << "L^(3/2) = "
+ << pow<static_rational<3,2> >(L) << std::endl
+ << "2vL = "
+ << root<2>(L) << std::endl
+ << "(3/2)vL = "
+ << root<static_rational<3,2> >(L) << std::endl
+ << std::endl;
+ }
+
+ {
+ //[quantity_snippet_2
+ quantity<length,std::complex<double> > L(std::complex<double>(3.0,4.0)*meters);
+ quantity<energy,std::complex<double> > E(kilograms*pow<2>(L/seconds));
+ //]
+
+ std::cout << "L = " << L << std::endl
+ << "L+L = " << L+L << std::endl
+ << "L-L = " << L-L << std::endl
+ << "L*L = " << L*L << std::endl
+ << "L/L = " << L/L << std::endl
+ << "L*meter = " << L*meter << std::endl
+ << "kilograms*(L/seconds)*(L/seconds) = "
+ << kilograms*(L/seconds)*(L/seconds) << std::endl
+ << "kilograms*(L/seconds)^2 = "
+ << kilograms*pow<2>(L/seconds) << std::endl
+ << "L^3 = "
+ << pow<3>(L) << std::endl
+ << "L^(3/2) = "
+ << pow<static_rational<3,2> >(L) << std::endl
+ << "2vL = "
+ << root<2>(L) << std::endl
+ << "(3/2)vL = "
+ << root<static_rational<3,2> >(L) << std::endl
+ << std::endl;
+ }
+
+ return 0;
+}
diff --git a/src/boost/libs/units/example/quaternion.cpp b/src/boost/libs/units/example/quaternion.cpp
new file mode 100644
index 000000000..a2e3e91bd
--- /dev/null
+++ b/src/boost/libs/units/example/quaternion.cpp
@@ -0,0 +1,232 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2007-2008 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)
+
+/**
+\file
+
+\brief quaternion.cpp
+
+\details
+Demonstrate interoperability with Boost.Quaternion.
+
+Output:
+@verbatim
+
+//[quaternion_output_1
++L = (4,3,2,1) m
+-L = (-4,-3,-2,-1) m
+L+L = (8,6,4,2) m
+L-L = (0,0,0,0) m
+L*L = (2,24,16,8) m^2
+L/L = (1,0,0,0) dimensionless
+L^3 = (-104,102,68,34) m^3
+//]
+
+//[quaternion_output_2
++L = (4 m,3 m,2 m,1 m)
+-L = (-4 m,-3 m,-2 m,-1 m)
+L+L = (8 m,6 m,4 m,2 m)
+L-L = (0 m,0 m,0 m,0 m)
+L^3 = (-104 m^3,102 m^3,68 m^3,34 m^3)
+//]
+
+@endverbatim
+**/
+
+#include <iostream>
+
+#include <boost/math/quaternion.hpp>
+#include <boost/mpl/list.hpp>
+
+#include <boost/units/pow.hpp>
+#include <boost/units/quantity.hpp>
+#include <boost/units/io.hpp>
+
+#include "test_system.hpp"
+
+#if BOOST_UNITS_HAS_BOOST_TYPEOF
+
+#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
+
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::math::quaternion, 1)
+
+#endif
+
+namespace boost {
+
+namespace units {
+
+//[quaternion_class_snippet_1a
+/// specialize power typeof helper
+template<class Y,long N,long D>
+struct power_typeof_helper<boost::math::quaternion<Y>,static_rational<N,D> >
+{
+ // boost::math::quaternion only supports integer powers
+ BOOST_STATIC_ASSERT(D==1);
+
+ typedef boost::math::quaternion<
+ typename power_typeof_helper<Y,static_rational<N,D> >::type
+ > type;
+
+ static type value(const boost::math::quaternion<Y>& x)
+ {
+ return boost::math::pow(x,static_cast<int>(N));
+ }
+};
+//]
+
+//[quaternion_class_snippet_1b
+/// specialize root typeof helper
+template<class Y,long N,long D>
+struct root_typeof_helper<boost::math::quaternion<Y>,static_rational<N,D> >
+{
+ // boost::math::quaternion only supports integer powers
+ BOOST_STATIC_ASSERT(N==1);
+
+ typedef boost::math::quaternion<
+ typename root_typeof_helper<Y,static_rational<N,D> >::type
+ > type;
+
+ static type value(const boost::math::quaternion<Y>& x)
+ {
+ return boost::math::pow(x,static_cast<int>(D));
+ }
+};
+//]
+
+//[quaternion_class_snippet_2a
+/// specialize power typeof helper for quaternion<quantity<Unit,Y> >
+template<class Unit,long N,long D,class Y>
+struct power_typeof_helper<
+ boost::math::quaternion<quantity<Unit,Y> >,
+ static_rational<N,D> >
+{
+ typedef typename power_typeof_helper<
+ Y,
+ static_rational<N,D>
+ >::type value_type;
+
+ typedef typename power_typeof_helper<
+ Unit,
+ static_rational<N,D>
+ >::type unit_type;
+
+ typedef quantity<unit_type,value_type> quantity_type;
+ typedef boost::math::quaternion<quantity_type> type;
+
+ static type value(const boost::math::quaternion<quantity<Unit,Y> >& x)
+ {
+ const boost::math::quaternion<value_type> tmp =
+ pow<static_rational<N,D> >(boost::math::quaternion<Y>(
+ x.R_component_1().value(),
+ x.R_component_2().value(),
+ x.R_component_3().value(),
+ x.R_component_4().value()));
+
+ return type(quantity_type::from_value(tmp.R_component_1()),
+ quantity_type::from_value(tmp.R_component_2()),
+ quantity_type::from_value(tmp.R_component_3()),
+ quantity_type::from_value(tmp.R_component_4()));
+ }
+};
+//]
+
+//[quaternion_class_snippet_2b
+/// specialize root typeof helper for quaternion<quantity<Unit,Y> >
+template<class Unit,long N,long D,class Y>
+struct root_typeof_helper<
+ boost::math::quaternion<quantity<Unit,Y> >,
+ static_rational<N,D> >
+{
+ typedef typename root_typeof_helper<
+ Y,
+ static_rational<N,D>
+ >::type value_type;
+
+ typedef typename root_typeof_helper<
+ Unit,
+ static_rational<N,D>
+ >::type unit_type;
+
+ typedef quantity<unit_type,value_type> quantity_type;
+ typedef boost::math::quaternion<quantity_type> type;
+
+ static type value(const boost::math::quaternion<quantity<Unit,Y> >& x)
+ {
+ const boost::math::quaternion<value_type> tmp =
+ root<static_rational<N,D> >(boost::math::quaternion<Y>(
+ x.R_component_1().value(),
+ x.R_component_2().value(),
+ x.R_component_3().value(),
+ x.R_component_4().value()));
+
+ return type(quantity_type::from_value(tmp.R_component_1()),
+ quantity_type::from_value(tmp.R_component_2()),
+ quantity_type::from_value(tmp.R_component_3()),
+ quantity_type::from_value(tmp.R_component_4()));
+ }
+};
+//]
+
+} // namespace units
+
+} // namespace boost
+
+int main(void)
+{
+ using boost::math::quaternion;
+ using namespace boost::units;
+ using namespace boost::units::test;
+ using boost::units::pow;
+
+ {
+ //[quaternion_snippet_1
+ typedef quantity<length,quaternion<double> > length_dimension;
+
+ length_dimension L(quaternion<double>(4.0,3.0,2.0,1.0)*meters);
+ //]
+
+ std::cout << "+L = " << +L << std::endl
+ << "-L = " << -L << std::endl
+ << "L+L = " << L+L << std::endl
+ << "L-L = " << L-L << std::endl
+ << "L*L = " << L*L << std::endl
+ << "L/L = " << L/L << std::endl
+ // unfortunately, without qualification msvc still
+ // finds boost::math::pow by ADL.
+ << "L^3 = " << boost::units::pow<3>(L) << std::endl
+// << "L^(3/2) = " << pow< static_rational<3,2> >(L) << std::endl
+// << "3vL = " << root<3>(L) << std::endl
+// << "(3/2)vL = " << root< static_rational<3,2> >(L) << std::endl
+ << std::endl;
+ }
+
+ {
+ //[quaternion_snippet_2
+ typedef quaternion<quantity<length> > length_dimension;
+
+ length_dimension L(4.0*meters,3.0*meters,2.0*meters,1.0*meters);
+ //]
+
+ std::cout << "+L = " << +L << std::endl
+ << "-L = " << -L << std::endl
+ << "L+L = " << L+L << std::endl
+ << "L-L = " << L-L << std::endl
+// << "L*L = " << L*L << std::endl
+// << "L/L = " << L/L << std::endl
+ << "L^3 = " << boost::units::pow<3>(L) << std::endl
+// << "L^(3/2) = " << pow< static_rational<3,2> >(L) << std::endl
+// << "3vL = " << root<3>(L) << std::endl
+// << "(3/2)vL = " << root< static_rational<3,2> >(L) << std::endl
+ << std::endl;
+ }
+
+ return 0;
+}
diff --git a/src/boost/libs/units/example/radar_beam_height.cpp b/src/boost/libs/units/example/radar_beam_height.cpp
new file mode 100644
index 000000000..00f1f902d
--- /dev/null
+++ b/src/boost/libs/units/example/radar_beam_height.cpp
@@ -0,0 +1,167 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2008 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)
+
+/**
+\file
+
+\brief radar_beam_height.cpp
+
+\details
+Demonstrate library usage for user test cases suggested by Michael Fawcett.
+
+Output:
+@verbatim
+
+//[radar_beam_height_output
+radar range : 300 nmi
+earth radius : 6.37101e+06 m
+beam height 1 : 18169.7 m
+beam height 2 : 9.81085 nmi
+beam height 3 : 18169.7 m
+beam height 4 : 9.81085 nmi
+beam height approx : 59488.4 ft
+beam height approx : 18132.1 m
+//]
+
+@endverbatim
+**/
+
+#include <iostream>
+
+#include <boost/units/conversion.hpp>
+#include <boost/units/io.hpp>
+#include <boost/units/pow.hpp>
+#include <boost/units/systems/si.hpp>
+#include <boost/units/systems/si/prefixes.hpp>
+
+using boost::units::length_dimension;
+using boost::units::pow;
+using boost::units::root;
+using boost::units::quantity;
+using boost::units::unit;
+
+//[radar_beam_height_class_snippet_1
+namespace nautical {
+
+struct length_base_unit :
+ boost::units::base_unit<length_base_unit, length_dimension, 1>
+{
+ static std::string name() { return "nautical mile"; }
+ static std::string symbol() { return "nmi"; }
+};
+
+typedef boost::units::make_system<length_base_unit>::type system;
+
+/// unit typedefs
+typedef unit<length_dimension,system> length;
+
+static const length mile,miles;
+
+} // namespace nautical
+
+// helper for conversions between nautical length and si length
+BOOST_UNITS_DEFINE_CONVERSION_FACTOR(nautical::length_base_unit,
+ boost::units::si::meter_base_unit,
+ double, 1.852e3);
+//]
+
+//[radar_beam_height_class_snippet_2
+namespace imperial {
+
+struct length_base_unit :
+ boost::units::base_unit<length_base_unit, length_dimension, 2>
+{
+ static std::string name() { return "foot"; }
+ static std::string symbol() { return "ft"; }
+};
+
+typedef boost::units::make_system<length_base_unit>::type system;
+
+/// unit typedefs
+typedef unit<length_dimension,system> length;
+
+static const length foot,feet;
+
+} // imperial
+
+// helper for conversions between imperial length and si length
+BOOST_UNITS_DEFINE_CONVERSION_FACTOR(imperial::length_base_unit,
+ boost::units::si::meter_base_unit,
+ double, 1.0/3.28083989501312);
+//]
+
+// radar beam height functions
+//[radar_beam_height_function_snippet_1
+template<class System,typename T>
+constexpr
+quantity<unit<boost::units::length_dimension,System>,T>
+radar_beam_height(const quantity<unit<length_dimension,System>,T>& radar_range,
+ const quantity<unit<length_dimension,System>,T>& earth_radius,
+ T k = 4.0/3.0)
+{
+ return quantity<unit<length_dimension,System>,T>
+ (pow<2>(radar_range)/(2.0*k*earth_radius));
+}
+//]
+
+//[radar_beam_height_function_snippet_2
+template<class return_type,class System1,class System2,typename T>
+constexpr
+return_type
+radar_beam_height(const quantity<unit<length_dimension,System1>,T>& radar_range,
+ const quantity<unit<length_dimension,System2>,T>& earth_radius,
+ T k = 4.0/3.0)
+{
+ // need to decide which system to use for calculation
+ return pow<2>(static_cast<return_type>(radar_range))
+ / (2.0*k*static_cast<return_type>(earth_radius));
+}
+//]
+
+//[radar_beam_height_function_snippet_3
+constexpr
+quantity<imperial::length>
+radar_beam_height(const quantity<nautical::length>& range)
+{
+ return quantity<imperial::length>
+ (pow<2>(range/(1.23*nautical::miles/root<2>(imperial::feet))));
+}
+//]
+
+int main(void)
+{
+ using namespace boost::units;
+ using namespace boost::units::si;
+ using namespace nautical;
+
+ //[radar_beam_height_snippet_1
+ const quantity<nautical::length> radar_range(300.0*miles);
+ const quantity<si::length> earth_radius(6371.0087714*kilo*meters);
+
+ const quantity<si::length> beam_height_1(radar_beam_height(quantity<si::length>(radar_range),earth_radius));
+ const quantity<nautical::length> beam_height_2(radar_beam_height(radar_range,quantity<nautical::length>(earth_radius)));
+ const quantity<si::length> beam_height_3(radar_beam_height< quantity<si::length> >(radar_range,earth_radius));
+ const quantity<nautical::length> beam_height_4(radar_beam_height< quantity<nautical::length> >(radar_range,earth_radius));
+ //]
+
+ std::cout << "radar range : " << radar_range << std::endl
+ << "earth radius : " << earth_radius << std::endl
+ << "beam height 1 : " << beam_height_1 << std::endl
+ << "beam height 2 : " << beam_height_2 << std::endl
+ << "beam height 3 : " << beam_height_3 << std::endl
+ << "beam height 4 : " << beam_height_4 << std::endl
+ << "beam height approx : " << radar_beam_height(radar_range)
+ << std::endl
+ << "beam height approx : "
+ << quantity<si::length>(radar_beam_height(radar_range))
+ << std::endl << std::endl;
+
+ return 0;
+}
diff --git a/src/boost/libs/units/example/runtime_conversion_factor.cpp b/src/boost/libs/units/example/runtime_conversion_factor.cpp
new file mode 100644
index 000000000..f814c884f
--- /dev/null
+++ b/src/boost/libs/units/example/runtime_conversion_factor.cpp
@@ -0,0 +1,72 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2008 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)
+
+#include <boost/units/base_dimension.hpp>
+#include <boost/units/base_unit.hpp>
+#include <boost/units/unit.hpp>
+#include <boost/units/quantity.hpp>
+
+//[runtime_conversion_factor_snippet_1
+
+using boost::units::base_dimension;
+using boost::units::base_unit;
+
+static const long currency_base = 1;
+
+struct currency_base_dimension : base_dimension<currency_base_dimension, 1> {};
+
+typedef currency_base_dimension::dimension_type currency_type;
+
+template<long N>
+struct currency_base_unit :
+ base_unit<currency_base_unit<N>, currency_type, currency_base + N> {};
+
+typedef currency_base_unit<0> us_dollar_base_unit;
+typedef currency_base_unit<1> euro_base_unit;
+
+typedef us_dollar_base_unit::unit_type us_dollar;
+typedef euro_base_unit::unit_type euro;
+
+// an array of all possible conversions
+double conversion_factors[2][2] = {
+ {1.0, 1.0},
+ {1.0, 1.0}
+};
+
+double get_conversion_factor(long from, long to) {
+ return(conversion_factors[from][to]);
+}
+
+void set_conversion_factor(long from, long to, double value) {
+ conversion_factors[from][to] = value;
+ conversion_factors[to][from] = 1.0 / value;
+}
+
+BOOST_UNITS_DEFINE_CONVERSION_FACTOR_TEMPLATE((long N1)(long N2),
+ currency_base_unit<N1>,
+ currency_base_unit<N2>,
+ double, get_conversion_factor(N1, N2));
+
+//]
+
+int main() {
+ boost::units::quantity<us_dollar> dollars = 2.00 * us_dollar();
+ boost::units::quantity<euro> euros(dollars);
+ set_conversion_factor(0, 1, 2.0);
+ dollars = static_cast<boost::units::quantity<us_dollar> >(euros);
+ set_conversion_factor(0, 1, .5);
+ euros = static_cast<boost::units::quantity<euro> >(dollars);
+ double value = euros.value(); // = .5
+ if(value != .5) {
+ return(1);
+ } else {
+ return(0);
+ }
+}
diff --git a/src/boost/libs/units/example/runtime_unit.cpp b/src/boost/libs/units/example/runtime_unit.cpp
new file mode 100644
index 000000000..5777facd0
--- /dev/null
+++ b/src/boost/libs/units/example/runtime_unit.cpp
@@ -0,0 +1,116 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2008 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)
+
+#include <map>
+#include <iostream>
+#include <boost/lexical_cast.hpp>
+#include <boost/units/quantity.hpp>
+#include <boost/units/cmath.hpp>
+#include <boost/units/systems/si/length.hpp>
+#include <boost/units/base_units/imperial/foot.hpp>
+
+//[runtime_unit_snippet_1
+
+namespace {
+
+using namespace boost::units;
+using imperial::foot_base_unit;
+
+std::map<std::string, quantity<si::length> > known_units;
+
+}
+
+quantity<si::length> calculate(const quantity<si::length>& t)
+{
+ return(boost::units::hypot(t, 2.0 * si::meters));
+}
+
+int main()
+{
+ known_units["meter"] = 1.0 * si::meters;
+ known_units["centimeter"] = .01 * si::meters;
+ known_units["foot"] =
+ conversion_factor(foot_base_unit::unit_type(), si::meter) * si::meter;
+
+ std::string output_type("meter");
+ std::string input;
+
+ while((std::cout << "> ") && (std::cin >> input))
+ {
+ if(!input.empty() && input[0] == '#')
+ {
+ std::getline(std::cin, input);
+ }
+ else if(input == "exit")
+ {
+ break;
+ }
+ else if(input == "help")
+ {
+ std::cout << "type \"exit\" to exit\n"
+ "type \"return 'unit'\" to set the return units\n"
+ "type \"'number' 'unit'\" to do a simple calculation"
+ << std::endl;
+ }
+ else if(input == "return")
+ {
+ if(std::cin >> input)
+ {
+ if(known_units.find(input) != known_units.end())
+ {
+ output_type = input;
+ std::cout << "Done." << std::endl;
+ }
+ else
+ {
+ std::cout << "Unknown unit \"" << input << "\""
+ << std::endl;
+ }
+ }
+ else
+ {
+ break;
+ }
+ }
+ else
+ {
+ try
+ {
+ double value = boost::lexical_cast<double>(input);
+
+ if(std::cin >> input)
+ {
+ if(known_units.find(input) != known_units.end())
+ {
+ std::cout << static_cast<double>(
+ calculate(value * known_units[input]) /
+ known_units[output_type])
+ << ' ' << output_type << std::endl;
+ }
+ else
+ {
+ std::cout << "Unknown unit \"" << input << "\""
+ << std::endl;
+ }
+ }
+ else
+ {
+ break;
+ }
+ }
+ catch(...)
+ {
+ std::cout << "Input error" << std::endl;
+ }
+ }
+ }
+}
+
+//]
diff --git a/src/boost/libs/units/example/runtime_unit_input.txt b/src/boost/libs/units/example/runtime_unit_input.txt
new file mode 100644
index 000000000..6c109e6c8
--- /dev/null
+++ b/src/boost/libs/units/example/runtime_unit_input.txt
@@ -0,0 +1,13 @@
+# runtime_unit_input.txt
+#
+# Copyright (c) 2007-2008 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)
+
+return foot
+2.0 centimeter
+return centimeter
+3.0 meter
+exit
diff --git a/src/boost/libs/units/example/systems.cpp b/src/boost/libs/units/example/systems.cpp
new file mode 100644
index 000000000..cbbce743a
--- /dev/null
+++ b/src/boost/libs/units/example/systems.cpp
@@ -0,0 +1,1072 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2008 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)
+
+/**
+\file
+
+\brief systems.cpp
+
+\details
+Test various non-si units
+
+Output:
+@verbatim
+
+@endverbatim
+**/
+
+#define BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(namespace_,unit_name_,dimension_) \
+namespace boost { \
+namespace units { \
+namespace namespace_ { \
+typedef make_system<unit_name_ ## _base_unit>::type unit_name_ ## system_; \
+typedef unit<dimension_ ## _dimension,unit_name_ ## system_> unit_name_ ## _ ## dimension_; \
+static constexpr unit_name_ ## _ ## dimension_ unit_name_ ## s; \
+} \
+} \
+} \
+
+#include <iostream>
+#include <sstream>
+#include <algorithm>
+
+#include <boost/units/conversion.hpp>
+#include <boost/units/io.hpp>
+#include <boost/units/pow.hpp>
+
+#include <boost/units/systems/cgs.hpp>
+#include <boost/units/systems/si.hpp>
+
+// angle base units
+#include <boost/units/base_units/angle/arcminute.hpp>
+#include <boost/units/base_units/angle/arcsecond.hpp>
+#include <boost/units/base_units/angle/degree.hpp>
+#include <boost/units/base_units/angle/gradian.hpp>
+#include <boost/units/base_units/angle/revolution.hpp>
+#include <boost/units/base_units/angle/radian.hpp>
+#include <boost/units/base_units/angle/steradian.hpp>
+
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(angle,arcminute,plane_angle)
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(angle,arcsecond,plane_angle)
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(angle,degree,plane_angle)
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(angle,gradian,plane_angle)
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(angle,radian,plane_angle)
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(angle,revolution,plane_angle)
+
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(angle,steradian,solid_angle)
+
+// astronomical base units
+#include <boost/units/base_units/astronomical/astronomical_unit.hpp>
+#include <boost/units/base_units/astronomical/light_second.hpp>
+#include <boost/units/base_units/astronomical/light_minute.hpp>
+#include <boost/units/base_units/astronomical/light_hour.hpp>
+#include <boost/units/base_units/astronomical/light_day.hpp>
+#include <boost/units/base_units/astronomical/light_year.hpp>
+#include <boost/units/base_units/astronomical/parsec.hpp>
+
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(astronomical,astronomical_unit,length)
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(astronomical,light_second,length)
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(astronomical,light_minute,length)
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(astronomical,light_hour,length)
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(astronomical,light_day,length)
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(astronomical,light_year,length)
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(astronomical,parsec,length)
+
+// imperial base units
+#include <boost/units/base_units/imperial/thou.hpp>
+#include <boost/units/base_units/imperial/inch.hpp>
+#include <boost/units/base_units/imperial/foot.hpp>
+#include <boost/units/base_units/imperial/yard.hpp>
+#include <boost/units/base_units/imperial/furlong.hpp>
+#include <boost/units/base_units/imperial/mile.hpp>
+#include <boost/units/base_units/imperial/league.hpp>
+
+#include <boost/units/base_units/imperial/grain.hpp>
+#include <boost/units/base_units/imperial/drachm.hpp>
+#include <boost/units/base_units/imperial/ounce.hpp>
+#include <boost/units/base_units/imperial/pound.hpp>
+#include <boost/units/base_units/imperial/stone.hpp>
+#include <boost/units/base_units/imperial/quarter.hpp>
+#include <boost/units/base_units/imperial/hundredweight.hpp>
+#include <boost/units/base_units/imperial/ton.hpp>
+
+#include <boost/units/base_units/imperial/fluid_ounce.hpp>
+#include <boost/units/base_units/imperial/gill.hpp>
+#include <boost/units/base_units/imperial/pint.hpp>
+#include <boost/units/base_units/imperial/quart.hpp>
+#include <boost/units/base_units/imperial/gallon.hpp>
+
+#include <boost/units/base_units/imperial/conversions.hpp>
+
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(imperial,thou,length)
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(imperial,inch,length)
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(imperial,foot,length)
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(imperial,yard,length)
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(imperial,furlong,length)
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(imperial,mile,length)
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(imperial,league,length)
+
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(imperial,grain,mass)
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(imperial,drachm,mass)
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(imperial,ounce,mass)
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(imperial,pound,mass)
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(imperial,stone,mass)
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(imperial,quarter,mass)
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(imperial,hundredweight,mass)
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(imperial,ton,mass)
+
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(imperial,fluid_ounce,volume)
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(imperial,gill,volume)
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(imperial,pint,volume)
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(imperial,quart,volume)
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(imperial,gallon,volume)
+
+// metric base units
+#include <boost/units/base_units/metric/angstrom.hpp>
+#include <boost/units/base_units/metric/fermi.hpp>
+#include <boost/units/base_units/metric/micron.hpp>
+#include <boost/units/base_units/metric/nautical_mile.hpp>
+
+#include <boost/units/base_units/metric/ton.hpp>
+
+#include <boost/units/base_units/metric/day.hpp>
+#include <boost/units/base_units/metric/hour.hpp>
+#include <boost/units/base_units/metric/minute.hpp>
+#include <boost/units/base_units/metric/year.hpp>
+
+#include <boost/units/base_units/metric/knot.hpp>
+
+#include <boost/units/base_units/metric/are.hpp>
+#include <boost/units/base_units/metric/barn.hpp>
+#include <boost/units/base_units/metric/hectare.hpp>
+
+#include <boost/units/base_units/metric/liter.hpp>
+
+#include <boost/units/base_units/metric/atmosphere.hpp>
+#include <boost/units/base_units/metric/bar.hpp>
+#include <boost/units/base_units/metric/mmHg.hpp>
+#include <boost/units/base_units/metric/torr.hpp>
+
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(metric,angstrom,length)
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(metric,fermi,length)
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(metric,micron,length)
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(metric,nautical_mile,length)
+
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(metric,ton,mass)
+
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(metric,day,time)
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(metric,hour,time)
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(metric,minute,time)
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(metric,year,time)
+
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(metric,knot,velocity)
+
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(metric,are,area)
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(metric,barn,area)
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(metric,hectare,area)
+
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(metric,liter,volume)
+
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(metric,atmosphere,pressure)
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(metric,bar,pressure)
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(metric,mmHg,pressure)
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(metric,torr,pressure)
+
+// us base units
+
+#include <boost/units/base_units/us/mil.hpp>
+#include <boost/units/base_units/us/inch.hpp>
+#include <boost/units/base_units/us/foot.hpp>
+#include <boost/units/base_units/us/yard.hpp>
+#include <boost/units/base_units/us/mile.hpp>
+
+#include <boost/units/base_units/us/grain.hpp>
+#include <boost/units/base_units/us/dram.hpp>
+#include <boost/units/base_units/us/ounce.hpp>
+#include <boost/units/base_units/us/pound.hpp>
+#include <boost/units/base_units/us/hundredweight.hpp>
+#include <boost/units/base_units/us/ton.hpp>
+
+#include <boost/units/base_units/us/minim.hpp>
+#include <boost/units/base_units/us/fluid_dram.hpp>
+#include <boost/units/base_units/us/teaspoon.hpp>
+#include <boost/units/base_units/us/tablespoon.hpp>
+#include <boost/units/base_units/us/fluid_ounce.hpp>
+#include <boost/units/base_units/us/gill.hpp>
+#include <boost/units/base_units/us/cup.hpp>
+#include <boost/units/base_units/us/pint.hpp>
+#include <boost/units/base_units/us/quart.hpp>
+#include <boost/units/base_units/us/gallon.hpp>
+
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(us,mil,length)
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(us,inch,length)
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(us,foot,length)
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(us,yard,length)
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(us,mile,length)
+
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(us,grain,mass)
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(us,dram,mass)
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(us,ounce,mass)
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(us,pound,mass)
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(us,hundredweight,mass)
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(us,ton,mass)
+
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(us,minim,volume)
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(us,fluid_dram,volume)
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(us,teaspoon,volume)
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(us,tablespoon,volume)
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(us,fluid_ounce,volume)
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(us,gill,volume)
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(us,cup,volume)
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(us,pint,volume)
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(us,quart,volume)
+BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(us,gallon,volume)
+
+int main(void)
+{
+ using namespace boost::units;
+
+ {
+ using namespace boost::units::angle;
+
+ std::cout << "Testing angle base units..." << std::endl;
+
+ quantity<arcsecond_plane_angle> as(1.0*arcseconds);
+ quantity<arcminute_plane_angle> am(1.0*arcminutes);
+ quantity<degree_plane_angle> d(1.0*degrees);
+ quantity<gradian_plane_angle> g(1.0*gradians);
+ quantity<radian_plane_angle> r(1.0*radians);
+ quantity<revolution_plane_angle> rev(1.0*revolutions);
+
+ std::cout << as << " = " << quantity<si::plane_angle>(as) << std::endl
+ << am << " = " << quantity<si::plane_angle>(am) << std::endl
+ << d << " = " << quantity<si::plane_angle>(d) << std::endl
+ << g << " = " << quantity<si::plane_angle>(g) << std::endl
+ << r << " = " << quantity<si::plane_angle>(r) << std::endl
+ << rev << " = " << quantity<si::plane_angle>(rev) << std::endl
+ << std::endl;
+
+ std::cout << rev << "/" << as << " = " << quantity<si::dimensionless>(rev/as) << std::endl
+ << rev << "/" << am << " = " << quantity<si::dimensionless>(rev/am) << std::endl
+ << rev << "/" << d << " = " << quantity<si::dimensionless>(rev/d) << std::endl
+ << rev << "/" << g << " = " << quantity<si::dimensionless>(rev/g) << std::endl
+ << rev << "/" << r << " = " << quantity<si::dimensionless>(rev/r) << std::endl
+ << std::endl;
+
+ // conversions only work with exponent of +/- 1 in scaled_base_unit?
+ std::cout << as << " = " << quantity<arcsecond_plane_angle>(as) << std::endl
+ << am << " = " << quantity<arcsecond_plane_angle>(am) << std::endl
+ << d << " = " << quantity<arcsecond_plane_angle>(d) << std::endl
+ << rev << " = " << quantity<arcsecond_plane_angle>(rev) << std::endl
+ << std::endl;
+
+ // conversions only work with exponent of +/- 1 in scaled_base_unit? see arcsecond.hpp
+ std::cout << as << " = " << quantity<arcminute_plane_angle>(as) << std::endl
+ << am << " = " << quantity<arcminute_plane_angle>(am) << std::endl
+ << d << " = " << quantity<arcminute_plane_angle>(d) << std::endl
+ << rev << " = " << quantity<arcminute_plane_angle>(rev) << std::endl
+ << std::endl;
+
+ std::cout << as << " = " << quantity<degree_plane_angle>(as) << std::endl
+ << am << " = " << quantity<degree_plane_angle>(am) << std::endl
+ << d << " = " << quantity<degree_plane_angle>(d) << std::endl
+ << rev << " = " << quantity<degree_plane_angle>(rev) << std::endl
+ << std::endl;
+
+ std::cout << as << " = " << quantity<revolution_plane_angle>(as) << std::endl
+ << am << " = " << quantity<revolution_plane_angle>(am) << std::endl
+ << d << " = " << quantity<revolution_plane_angle>(d) << std::endl
+ << rev << " = " << quantity<revolution_plane_angle>(rev) << std::endl
+ << std::endl;
+
+ quantity<steradian_solid_angle> sa1(1.0*steradians);
+
+ std::cout << sa1 << std::endl
+ << std::endl;
+ }
+
+ {
+ using namespace boost::units::astronomical;
+
+ std::cout << "Testing astronomical base units..." << std::endl;
+
+ quantity<light_second_length> ls(1.0*light_seconds);
+ quantity<light_minute_length> lm(1.0*light_minutes);
+ quantity<astronomical_unit_length> au(1.0*astronomical_units);
+ quantity<light_hour_length> lh(1.0*light_hours);
+ quantity<light_day_length> ld(1.0*light_days);
+ quantity<light_year_length> ly(1.0*light_years);
+ quantity<parsec_length> ps(1.0*parsecs);
+
+ std::cout << ls << " = " << quantity<si::length>(ls) << std::endl
+ << lm << " = " << quantity<si::length>(lm) << std::endl
+ << au << " = " << quantity<si::length>(au) << std::endl
+ << lh << " = " << quantity<si::length>(lh) << std::endl
+ << ld << " = " << quantity<si::length>(ld) << std::endl
+ << ly << " = " << quantity<si::length>(ly) << std::endl
+ << ps << " = " << quantity<si::length>(ps) << std::endl
+ << std::endl;
+
+ std::cout << ly << "/" << ls << " = " << quantity<si::dimensionless>(ly/ls) << std::endl
+ << ly << "/" << lm << " = " << quantity<si::dimensionless>(ly/lm) << std::endl
+ << ly << "/" << au << " = " << quantity<si::dimensionless>(ly/au) << std::endl
+ << ly << "/" << lh << " = " << quantity<si::dimensionless>(ly/ld) << std::endl
+ << ly << "/" << ld << " = " << quantity<si::dimensionless>(ly/lh) << std::endl
+ << ly << "/" << ps << " = " << quantity<si::dimensionless>(ly/ps) << std::endl
+ << std::endl;
+
+ std::cout << ls << " = " << quantity<light_second_length>(ls) << std::endl
+ << lm << " = " << quantity<light_second_length>(lm) << std::endl
+ << lh << " = " << quantity<light_second_length>(lh) << std::endl
+ << ld << " = " << quantity<light_second_length>(ld) << std::endl
+ << ly << " = " << quantity<light_second_length>(ly) << std::endl
+ << std::endl;
+
+ std::cout << ls << " = " << quantity<light_minute_length>(ls) << std::endl
+ << lm << " = " << quantity<light_minute_length>(lm) << std::endl
+ << lh << " = " << quantity<light_minute_length>(lh) << std::endl
+ << ld << " = " << quantity<light_minute_length>(ld) << std::endl
+ << ly << " = " << quantity<light_minute_length>(ly) << std::endl
+ << std::endl;
+
+ std::cout << ls << " = " << quantity<light_hour_length>(ls) << std::endl
+ << lm << " = " << quantity<light_hour_length>(lm) << std::endl
+ << lh << " = " << quantity<light_hour_length>(lh) << std::endl
+ << ld << " = " << quantity<light_hour_length>(ld) << std::endl
+ << ly << " = " << quantity<light_hour_length>(ly) << std::endl
+ << std::endl;
+
+ std::cout << ls << " = " << quantity<light_day_length>(ls) << std::endl
+ << lm << " = " << quantity<light_day_length>(lm) << std::endl
+ << lh << " = " << quantity<light_day_length>(lh) << std::endl
+ << ld << " = " << quantity<light_day_length>(ld) << std::endl
+ << ly << " = " << quantity<light_day_length>(ly) << std::endl
+ << std::endl;
+
+ std::cout << ls << " = " << quantity<light_year_length>(ls) << std::endl
+ << lm << " = " << quantity<light_year_length>(lm) << std::endl
+ << lh << " = " << quantity<light_year_length>(ld) << std::endl
+ << ld << " = " << quantity<light_year_length>(lh) << std::endl
+ << ly << " = " << quantity<light_year_length>(ly) << std::endl
+ << std::endl;
+ }
+
+ {
+ using namespace boost::units::imperial;
+
+ std::cout << "Testing imperial base units..." << std::endl;
+
+ quantity<thou_length> iml1(1.0*thous);
+ quantity<inch_length> iml2(1.0*inchs);
+ quantity<foot_length> iml3(1.0*foots);
+ quantity<yard_length> iml4(1.0*yards);
+ quantity<furlong_length> iml5(1.0*furlongs);
+ quantity<mile_length> iml6(1.0*miles);
+ quantity<league_length> iml7(1.0*leagues);
+
+ std::cout << iml1 << " = " << quantity<si::length>(iml1) << std::endl
+ << iml2 << " = " << quantity<si::length>(iml2) << std::endl
+ << iml3 << " = " << quantity<si::length>(iml3) << std::endl
+ << iml4 << " = " << quantity<si::length>(iml4) << std::endl
+ << iml5 << " = " << quantity<si::length>(iml5) << std::endl
+ << iml6 << " = " << quantity<si::length>(iml6) << std::endl
+ << iml7 << " = " << quantity<si::length>(iml7) << std::endl
+ << std::endl;
+
+ std::cout << iml7 << "/" << iml1 << " = " << quantity<si::dimensionless>(iml7/iml1) << std::endl
+ << iml7 << "/" << iml2 << " = " << quantity<si::dimensionless>(iml7/iml2) << std::endl
+ << iml7 << "/" << iml3 << " = " << quantity<si::dimensionless>(iml7/iml3) << std::endl
+ << iml7 << "/" << iml4 << " = " << quantity<si::dimensionless>(iml7/iml4) << std::endl
+ << iml7 << "/" << iml5 << " = " << quantity<si::dimensionless>(iml7/iml5) << std::endl
+ << iml7 << "/" << iml6 << " = " << quantity<si::dimensionless>(iml7/iml6) << std::endl
+ << std::endl;
+
+ std::cout << iml1 << " = " << quantity<thou_length>(iml1) << std::endl
+ << iml2 << " = " << quantity<thou_length>(iml2) << std::endl
+ << iml3 << " = " << quantity<thou_length>(iml3) << std::endl
+ << iml4 << " = " << quantity<thou_length>(iml4) << std::endl
+ << iml5 << " = " << quantity<thou_length>(iml5) << std::endl
+ << iml6 << " = " << quantity<thou_length>(iml6) << std::endl
+ << iml7 << " = " << quantity<thou_length>(iml7) << std::endl
+ << std::endl;
+
+ std::cout << iml1 << " = " << quantity<inch_length>(iml1) << std::endl
+ << iml2 << " = " << quantity<inch_length>(iml2) << std::endl
+ << iml3 << " = " << quantity<inch_length>(iml3) << std::endl
+ << iml4 << " = " << quantity<inch_length>(iml4) << std::endl
+ << iml5 << " = " << quantity<inch_length>(iml5) << std::endl
+ << iml6 << " = " << quantity<inch_length>(iml6) << std::endl
+ << iml7 << " = " << quantity<inch_length>(iml7) << std::endl
+ << std::endl;
+
+ std::cout << iml1 << " = " << quantity<foot_length>(iml1) << std::endl
+ << iml2 << " = " << quantity<foot_length>(iml2) << std::endl
+ << iml3 << " = " << quantity<foot_length>(iml3) << std::endl
+ << iml4 << " = " << quantity<foot_length>(iml4) << std::endl
+ << iml5 << " = " << quantity<foot_length>(iml5) << std::endl
+ << iml6 << " = " << quantity<foot_length>(iml6) << std::endl
+ << iml7 << " = " << quantity<foot_length>(iml7) << std::endl
+ << std::endl;
+
+ std::cout << iml1 << " = " << quantity<yard_length>(iml1) << std::endl
+ << iml2 << " = " << quantity<yard_length>(iml2) << std::endl
+ << iml3 << " = " << quantity<yard_length>(iml3) << std::endl
+ << iml4 << " = " << quantity<yard_length>(iml4) << std::endl
+ << iml5 << " = " << quantity<yard_length>(iml5) << std::endl
+ << iml6 << " = " << quantity<yard_length>(iml6) << std::endl
+ << iml7 << " = " << quantity<yard_length>(iml7) << std::endl
+ << std::endl;
+
+ std::cout << iml1 << " = " << quantity<furlong_length>(iml1) << std::endl
+ << iml2 << " = " << quantity<furlong_length>(iml2) << std::endl
+ << iml3 << " = " << quantity<furlong_length>(iml3) << std::endl
+ << iml4 << " = " << quantity<furlong_length>(iml4) << std::endl
+ << iml5 << " = " << quantity<furlong_length>(iml5) << std::endl
+ << iml6 << " = " << quantity<furlong_length>(iml6) << std::endl
+ << iml7 << " = " << quantity<furlong_length>(iml7) << std::endl
+ << std::endl;
+
+ std::cout << iml1 << " = " << quantity<mile_length>(iml1) << std::endl
+ << iml2 << " = " << quantity<mile_length>(iml2) << std::endl
+ << iml3 << " = " << quantity<mile_length>(iml3) << std::endl
+ << iml4 << " = " << quantity<mile_length>(iml4) << std::endl
+ << iml5 << " = " << quantity<mile_length>(iml5) << std::endl
+ << iml6 << " = " << quantity<mile_length>(iml6) << std::endl
+ << iml7 << " = " << quantity<mile_length>(iml7) << std::endl
+ << std::endl;
+
+ std::cout << iml1 << " = " << quantity<league_length>(iml1) << std::endl
+ << iml2 << " = " << quantity<league_length>(iml2) << std::endl
+ << iml3 << " = " << quantity<league_length>(iml3) << std::endl
+ << iml4 << " = " << quantity<league_length>(iml4) << std::endl
+ << iml5 << " = " << quantity<league_length>(iml5) << std::endl
+ << iml6 << " = " << quantity<league_length>(iml6) << std::endl
+ << iml7 << " = " << quantity<league_length>(iml7) << std::endl
+ << std::endl;
+
+ quantity<grain_mass> imm1(1.0*grains);
+ quantity<drachm_mass> imm2(1.0*drachms);
+ quantity<ounce_mass> imm3(1.0*ounces);
+ quantity<pound_mass> imm4(1.0*pounds);
+ quantity<stone_mass> imm5(1.0*stones);
+ quantity<quarter_mass> imm6(1.0*quarters);
+ quantity<hundredweight_mass> imm7(1.0*hundredweights);
+ quantity<ton_mass> imm8(1.0*tons);
+
+ std::cout << imm1 << " = " << quantity<si::mass>(imm1) << std::endl
+ << imm2 << " = " << quantity<si::mass>(imm2) << std::endl
+ << imm3 << " = " << quantity<si::mass>(imm3) << std::endl
+ << imm4 << " = " << quantity<si::mass>(imm4) << std::endl
+ << imm5 << " = " << quantity<si::mass>(imm5) << std::endl
+ << imm6 << " = " << quantity<si::mass>(imm6) << std::endl
+ << imm7 << " = " << quantity<si::mass>(imm7) << std::endl
+ << imm8 << " = " << quantity<si::mass>(imm8) << std::endl
+ << std::endl;
+
+ std::cout << imm8 << "/" << imm1 << " = " << quantity<si::dimensionless>(imm8/imm1) << std::endl
+ << imm8 << "/" << imm2 << " = " << quantity<si::dimensionless>(imm8/imm2) << std::endl
+ << imm8 << "/" << imm3 << " = " << quantity<si::dimensionless>(imm8/imm3) << std::endl
+ << imm8 << "/" << imm4 << " = " << quantity<si::dimensionless>(imm8/imm4) << std::endl
+ << imm8 << "/" << imm5 << " = " << quantity<si::dimensionless>(imm8/imm5) << std::endl
+ << imm8 << "/" << imm6 << " = " << quantity<si::dimensionless>(imm8/imm6) << std::endl
+ << imm8 << "/" << imm7 << " = " << quantity<si::dimensionless>(imm8/imm7) << std::endl
+ << std::endl;
+
+ std::cout << imm1 << " = " << quantity<grain_mass>(imm1) << std::endl
+ << imm2 << " = " << quantity<grain_mass>(imm2) << std::endl
+ << imm3 << " = " << quantity<grain_mass>(imm3) << std::endl
+ << imm4 << " = " << quantity<grain_mass>(imm4) << std::endl
+ << imm5 << " = " << quantity<grain_mass>(imm5) << std::endl
+ << imm6 << " = " << quantity<grain_mass>(imm6) << std::endl
+ << imm7 << " = " << quantity<grain_mass>(imm7) << std::endl
+ << imm8 << " = " << quantity<grain_mass>(imm8) << std::endl
+ << std::endl;
+
+ std::cout << imm1 << " = " << quantity<drachm_mass>(imm1) << std::endl
+ << imm2 << " = " << quantity<drachm_mass>(imm2) << std::endl
+ << imm3 << " = " << quantity<drachm_mass>(imm3) << std::endl
+ << imm4 << " = " << quantity<drachm_mass>(imm4) << std::endl
+ << imm5 << " = " << quantity<drachm_mass>(imm5) << std::endl
+ << imm6 << " = " << quantity<drachm_mass>(imm6) << std::endl
+ << imm7 << " = " << quantity<drachm_mass>(imm7) << std::endl
+ << imm8 << " = " << quantity<drachm_mass>(imm8) << std::endl
+ << std::endl;
+
+ std::cout << imm1 << " = " << quantity<ounce_mass>(imm1) << std::endl
+ << imm2 << " = " << quantity<ounce_mass>(imm2) << std::endl
+ << imm3 << " = " << quantity<ounce_mass>(imm3) << std::endl
+ << imm4 << " = " << quantity<ounce_mass>(imm4) << std::endl
+ << imm5 << " = " << quantity<ounce_mass>(imm5) << std::endl
+ << imm6 << " = " << quantity<ounce_mass>(imm6) << std::endl
+ << imm7 << " = " << quantity<ounce_mass>(imm7) << std::endl
+ << imm8 << " = " << quantity<ounce_mass>(imm8) << std::endl
+ << std::endl;
+
+ std::cout << imm1 << " = " << quantity<pound_mass>(imm1) << std::endl
+ << imm2 << " = " << quantity<pound_mass>(imm2) << std::endl
+ << imm3 << " = " << quantity<pound_mass>(imm3) << std::endl
+ << imm4 << " = " << quantity<pound_mass>(imm4) << std::endl
+ << imm5 << " = " << quantity<pound_mass>(imm5) << std::endl
+ << imm6 << " = " << quantity<pound_mass>(imm6) << std::endl
+ << imm7 << " = " << quantity<pound_mass>(imm7) << std::endl
+ << imm8 << " = " << quantity<pound_mass>(imm8) << std::endl
+ << std::endl;
+
+ std::cout << imm1 << " = " << quantity<stone_mass>(imm1) << std::endl
+ << imm2 << " = " << quantity<stone_mass>(imm2) << std::endl
+ << imm3 << " = " << quantity<stone_mass>(imm3) << std::endl
+ << imm4 << " = " << quantity<stone_mass>(imm4) << std::endl
+ << imm5 << " = " << quantity<stone_mass>(imm5) << std::endl
+ << imm6 << " = " << quantity<stone_mass>(imm6) << std::endl
+ << imm7 << " = " << quantity<stone_mass>(imm7) << std::endl
+ << imm8 << " = " << quantity<stone_mass>(imm8) << std::endl
+ << std::endl;
+
+ std::cout << imm1 << " = " << quantity<quarter_mass>(imm1) << std::endl
+ << imm2 << " = " << quantity<quarter_mass>(imm2) << std::endl
+ << imm3 << " = " << quantity<quarter_mass>(imm3) << std::endl
+ << imm4 << " = " << quantity<quarter_mass>(imm4) << std::endl
+ << imm5 << " = " << quantity<quarter_mass>(imm5) << std::endl
+ << imm6 << " = " << quantity<quarter_mass>(imm6) << std::endl
+ << imm7 << " = " << quantity<quarter_mass>(imm7) << std::endl
+ << imm8 << " = " << quantity<quarter_mass>(imm8) << std::endl
+ << std::endl;
+
+ std::cout << imm1 << " = " << quantity<hundredweight_mass>(imm1) << std::endl
+ << imm2 << " = " << quantity<hundredweight_mass>(imm2) << std::endl
+ << imm3 << " = " << quantity<hundredweight_mass>(imm3) << std::endl
+ << imm4 << " = " << quantity<hundredweight_mass>(imm4) << std::endl
+ << imm5 << " = " << quantity<hundredweight_mass>(imm5) << std::endl
+ << imm6 << " = " << quantity<hundredweight_mass>(imm6) << std::endl
+ << imm7 << " = " << quantity<hundredweight_mass>(imm7) << std::endl
+ << imm8 << " = " << quantity<hundredweight_mass>(imm8) << std::endl
+ << std::endl;
+
+ std::cout << imm1 << " = " << quantity<ton_mass>(imm1) << std::endl
+ << imm2 << " = " << quantity<ton_mass>(imm2) << std::endl
+ << imm3 << " = " << quantity<ton_mass>(imm3) << std::endl
+ << imm4 << " = " << quantity<ton_mass>(imm4) << std::endl
+ << imm5 << " = " << quantity<ton_mass>(imm5) << std::endl
+ << imm6 << " = " << quantity<ton_mass>(imm6) << std::endl
+ << imm7 << " = " << quantity<ton_mass>(imm7) << std::endl
+ << imm8 << " = " << quantity<ton_mass>(imm8) << std::endl
+ << std::endl;
+
+ quantity<fluid_ounce_volume> imv1(1.0*fluid_ounces);
+ quantity<gill_volume> imv2(1.0*gills);
+ quantity<pint_volume> imv3(1.0*pints);
+ quantity<quart_volume> imv4(1.0*quarts);
+ quantity<gallon_volume> imv5(1.0*gallons);
+
+ std::cout << imv1 << " = " << quantity<si::volume>(imv1) << std::endl
+ << imv2 << " = " << quantity<si::volume>(imv2) << std::endl
+ << imv3 << " = " << quantity<si::volume>(imv3) << std::endl
+ << imv4 << " = " << quantity<si::volume>(imv4) << std::endl
+ << imv5 << " = " << quantity<si::volume>(imv5) << std::endl
+ << std::endl;
+
+ std::cout << imv5 << "/" << imv1 << " = " << quantity<si::dimensionless>(imv5/imv1) << std::endl
+ << imv5 << "/" << imv2 << " = " << quantity<si::dimensionless>(imv5/imv2) << std::endl
+ << imv5 << "/" << imv3 << " = " << quantity<si::dimensionless>(imv5/imv3) << std::endl
+ << imv5 << "/" << imv4 << " = " << quantity<si::dimensionless>(imv5/imv4) << std::endl
+ << std::endl;
+
+ std::cout << imv1 << " = " << quantity<fluid_ounce_volume>(imv1) << std::endl
+ << imv2 << " = " << quantity<fluid_ounce_volume>(imv2) << std::endl
+ << imv3 << " = " << quantity<fluid_ounce_volume>(imv3) << std::endl
+ << imv4 << " = " << quantity<fluid_ounce_volume>(imv4) << std::endl
+ << imv5 << " = " << quantity<fluid_ounce_volume>(imv5) << std::endl
+ << std::endl;
+
+ std::cout << imv1 << " = " << quantity<gill_volume>(imv1) << std::endl
+ << imv2 << " = " << quantity<gill_volume>(imv2) << std::endl
+ << imv3 << " = " << quantity<gill_volume>(imv3) << std::endl
+ << imv4 << " = " << quantity<gill_volume>(imv4) << std::endl
+ << imv5 << " = " << quantity<gill_volume>(imv5) << std::endl
+ << std::endl;
+
+ std::cout << imv1 << " = " << quantity<pint_volume>(imv1) << std::endl
+ << imv2 << " = " << quantity<pint_volume>(imv2) << std::endl
+ << imv3 << " = " << quantity<pint_volume>(imv3) << std::endl
+ << imv4 << " = " << quantity<pint_volume>(imv4) << std::endl
+ << imv5 << " = " << quantity<pint_volume>(imv5) << std::endl
+ << std::endl;
+
+ std::cout << imv1 << " = " << quantity<quart_volume>(imv1) << std::endl
+ << imv2 << " = " << quantity<quart_volume>(imv2) << std::endl
+ << imv3 << " = " << quantity<quart_volume>(imv3) << std::endl
+ << imv4 << " = " << quantity<quart_volume>(imv4) << std::endl
+ << imv5 << " = " << quantity<quart_volume>(imv5) << std::endl
+ << std::endl;
+
+ std::cout << imv1 << " = " << quantity<gallon_volume>(imv1) << std::endl
+ << imv2 << " = " << quantity<gallon_volume>(imv2) << std::endl
+ << imv3 << " = " << quantity<gallon_volume>(imv3) << std::endl
+ << imv4 << " = " << quantity<gallon_volume>(imv4) << std::endl
+ << imv5 << " = " << quantity<gallon_volume>(imv5) << std::endl
+ << std::endl;
+ }
+
+ {
+ using namespace boost::units::metric;
+
+ std::cout << "Testing metric base units..." << std::endl;
+
+ quantity<fermi_length> ml1(1.0*fermis);
+ quantity<angstrom_length> ml2(1.0*angstroms);
+ quantity<micron_length> ml3(1.0*microns);
+ quantity<nautical_mile_length> ml4(1.0*nautical_miles);
+
+ std::cout << ml1 << " = " << quantity<si::length>(ml1) << std::endl
+ << ml2 << " = " << quantity<si::length>(ml2) << std::endl
+ << ml3 << " = " << quantity<si::length>(ml3) << std::endl
+ << ml4 << " = " << quantity<si::length>(ml4) << std::endl
+ << std::endl;
+
+ std::cout << ml4 << "/" << ml1 << " = " << quantity<si::dimensionless>(ml4/ml1) << std::endl
+ << ml4 << "/" << ml2 << " = " << quantity<si::dimensionless>(ml4/ml2) << std::endl
+ << ml4 << "/" << ml3 << " = " << quantity<si::dimensionless>(ml4/ml3) << std::endl
+ << std::endl;
+
+ std::cout << ml1 << " = " << quantity<fermi_length>(ml1) << std::endl
+ << ml2 << " = " << quantity<fermi_length>(ml2) << std::endl
+ << ml3 << " = " << quantity<fermi_length>(ml3) << std::endl
+ << ml4 << " = " << quantity<fermi_length>(ml4) << std::endl
+ << std::endl;
+
+ std::cout << ml1 << " = " << quantity<angstrom_length>(ml1) << std::endl
+ << ml2 << " = " << quantity<angstrom_length>(ml2) << std::endl
+ << ml3 << " = " << quantity<angstrom_length>(ml3) << std::endl
+ << ml4 << " = " << quantity<angstrom_length>(ml4) << std::endl
+ << std::endl;
+
+ std::cout << ml1 << " = " << quantity<micron_length>(ml1) << std::endl
+ << ml2 << " = " << quantity<micron_length>(ml2) << std::endl
+ << ml3 << " = " << quantity<micron_length>(ml3) << std::endl
+ << ml4 << " = " << quantity<micron_length>(ml4) << std::endl
+ << std::endl;
+
+ std::cout << ml1 << " = " << quantity<nautical_mile_length>(ml1) << std::endl
+ << ml2 << " = " << quantity<nautical_mile_length>(ml2) << std::endl
+ << ml3 << " = " << quantity<nautical_mile_length>(ml3) << std::endl
+ << ml4 << " = " << quantity<nautical_mile_length>(ml4) << std::endl
+ << std::endl;
+
+ quantity<ton_mass> mm1(1.0*tons);
+
+ std::cout << mm1 << " = " << quantity<cgs::mass>(mm1) << std::endl
+ //<< quantity<si::mass>(mm1) << std::endl // this should work...
+ << std::endl;
+
+ quantity<minute_time> mt1(1.0*minutes);
+ quantity<hour_time> mt2(1.0*hours);
+ quantity<day_time> mt3(1.0*days);
+ quantity<year_time> mt4(1.0*years);
+
+ std::cout << mt1 << " = " << quantity<si::time>(mt1) << std::endl
+ << mt2 << " = " << quantity<si::time>(mt2) << std::endl
+ << mt3 << " = " << quantity<si::time>(mt3) << std::endl
+ << mt4 << " = " << quantity<si::time>(mt4) << std::endl
+ << std::endl;
+
+ std::cout << mt4 << "/" << mt1 << " = " << quantity<si::dimensionless>(mt4/mt1) << std::endl
+ << mt4 << "/" << mt2 << " = " << quantity<si::dimensionless>(mt4/mt2) << std::endl
+ << mt4 << "/" << mt3 << " = " << quantity<si::dimensionless>(mt4/mt3) << std::endl
+ << std::endl;
+
+ std::cout << mt1 << " = " << quantity<minute_time>(mt1) << std::endl
+ << mt2 << " = " << quantity<minute_time>(mt2) << std::endl
+ << mt3 << " = " << quantity<minute_time>(mt3) << std::endl
+ << mt4 << " = " << quantity<minute_time>(mt4) << std::endl
+ << std::endl;
+
+ std::cout << mt1 << " = " << quantity<hour_time>(mt1) << std::endl
+ << mt2 << " = " << quantity<hour_time>(mt2) << std::endl
+ << mt3 << " = " << quantity<hour_time>(mt3) << std::endl
+ << mt4 << " = " << quantity<hour_time>(mt4) << std::endl
+ << std::endl;
+
+ std::cout << mt1 << " = " << quantity<day_time>(mt1) << std::endl
+ << mt2 << " = " << quantity<day_time>(mt2) << std::endl
+ << mt3 << " = " << quantity<day_time>(mt3) << std::endl
+ << mt4 << " = " << quantity<day_time>(mt4) << std::endl
+ << std::endl;
+
+ std::cout << mt1 << " = " << quantity<year_time>(mt1) << std::endl
+ << mt2 << " = " << quantity<year_time>(mt2) << std::endl
+ << mt3 << " = " << quantity<year_time>(mt3) << std::endl
+ << mt4 << " = " << quantity<year_time>(mt4) << std::endl
+ << std::endl;
+
+ quantity<knot_velocity> ms1(1.0*knots);
+
+ std::cout << ms1 << " = " << quantity<si::velocity>(ms1) << std::endl
+ << std::endl;
+
+ quantity<barn_area> ma1(1.0*barns);
+ quantity<are_area> ma2(1.0*ares);
+ quantity<hectare_area> ma3(1.0*hectares);
+
+ std::cout << ma1 << " = " << quantity<si::area>(ma1) << std::endl
+ << ma2 << " = " << quantity<si::area>(ma2) << std::endl
+ << ma3 << " = " << quantity<si::area>(ma3) << std::endl
+ << std::endl;
+
+ std::cout << ma3 << "/" << ma1 << " = " << quantity<si::dimensionless>(ma3/ma1) << std::endl
+ << ma3 << "/" << ma2 << " = " << quantity<si::dimensionless>(ma3/ma2) << std::endl
+ << std::endl;
+
+ std::cout << ma1 << " = " << quantity<barn_area>(ma1) << std::endl
+ << ma2 << " = " << quantity<barn_area>(ma2) << std::endl
+ << ma3 << " = " << quantity<barn_area>(ma3) << std::endl
+ << std::endl;
+
+ std::cout << ma1 << " = " << quantity<are_area>(ma1) << std::endl
+ << ma2 << " = " << quantity<are_area>(ma2) << std::endl
+ << ma3 << " = " << quantity<are_area>(ma3) << std::endl
+ << std::endl;
+
+ std::cout << ma1 << " = " << quantity<hectare_area>(ma1) << std::endl
+ << ma2 << " = " << quantity<hectare_area>(ma2) << std::endl
+ << ma3 << " = " << quantity<hectare_area>(ma3) << std::endl
+ << std::endl;
+
+ quantity<liter_volume> mv1(1.0*liters);
+
+ std::cout << mv1 << " = " << quantity<si::volume>(mv1) << std::endl
+ << std::endl;
+
+ quantity<mmHg_pressure> mp1(1.0*mmHgs);
+ quantity<torr_pressure> mp2(1.0*torrs);
+ quantity<bar_pressure> mp3(1.0*bars);
+ quantity<atmosphere_pressure> mp4(1.0*atmospheres);
+
+ std::cout << mp1 << " = " << quantity<si::pressure>(mp1) << std::endl
+ << mp2 << " = " << quantity<si::pressure>(mp2) << std::endl
+ << mp3 << " = " << quantity<si::pressure>(mp3) << std::endl
+ << mp4 << " = " << quantity<si::pressure>(mp4) << std::endl
+ << std::endl;
+
+ std::cout << mp4 << "/" << mp1 << " = " << quantity<si::dimensionless>(mp4/mp1) << std::endl
+ << mp4 << "/" << mp2 << " = " << quantity<si::dimensionless>(mp4/mp2) << std::endl
+ << mp4 << "/" << mp3 << " = " << quantity<si::dimensionless>(mp4/mp3) << std::endl
+ << std::endl;
+
+ std::cout << mp1 << " = " << quantity<mmHg_pressure>(mp1) << std::endl
+ << mp2 << " = " << quantity<mmHg_pressure>(mp2) << std::endl
+ << mp3 << " = " << quantity<mmHg_pressure>(mp3) << std::endl
+ << mp4 << " = " << quantity<mmHg_pressure>(mp4) << std::endl
+ << std::endl;
+
+ std::cout << mp1 << " = " << quantity<torr_pressure>(mp1) << std::endl
+ << mp2 << " = " << quantity<torr_pressure>(mp2) << std::endl
+ << mp3 << " = " << quantity<torr_pressure>(mp3) << std::endl
+ << mp4 << " = " << quantity<torr_pressure>(mp4) << std::endl
+ << std::endl;
+
+ std::cout << mp1 << " = " << quantity<bar_pressure>(mp1) << std::endl
+ << mp2 << " = " << quantity<bar_pressure>(mp2) << std::endl
+ << mp3 << " = " << quantity<bar_pressure>(mp3) << std::endl
+ << mp4 << " = " << quantity<bar_pressure>(mp4) << std::endl
+ << std::endl;
+
+ std::cout << mp1 << " = " << quantity<atmosphere_pressure>(mp1) << std::endl
+ << mp2 << " = " << quantity<atmosphere_pressure>(mp2) << std::endl
+ << mp3 << " = " << quantity<atmosphere_pressure>(mp3) << std::endl
+ << mp4 << " = " << quantity<atmosphere_pressure>(mp4) << std::endl
+ << std::endl;
+ }
+
+ {
+ using namespace boost::units::us;
+
+ std::cout << "Testing U.S. customary base units..." << std::endl;
+
+ quantity<mil_length> iml1(1.0*mils);
+ quantity<inch_length> iml2(1.0*inchs);
+ quantity<foot_length> iml3(1.0*foots);
+ quantity<yard_length> iml4(1.0*yards);
+ quantity<mile_length> iml5(1.0*miles);
+
+ std::cout << iml1 << " = " << quantity<si::length>(iml1) << std::endl
+ << iml2 << " = " << quantity<si::length>(iml2) << std::endl
+ << iml3 << " = " << quantity<si::length>(iml3) << std::endl
+ << iml4 << " = " << quantity<si::length>(iml4) << std::endl
+ << iml5 << " = " << quantity<si::length>(iml5) << std::endl
+ << std::endl;
+
+ std::cout << iml5 << "/" << iml1 << " = " << quantity<si::dimensionless>(iml5/iml1) << std::endl
+ << iml5 << "/" << iml2 << " = " << quantity<si::dimensionless>(iml5/iml2) << std::endl
+ << iml5 << "/" << iml3 << " = " << quantity<si::dimensionless>(iml5/iml3) << std::endl
+ << iml5 << "/" << iml4 << " = " << quantity<si::dimensionless>(iml5/iml4) << std::endl
+ << std::endl;
+
+ std::cout << iml1 << " = " << quantity<mil_length>(iml1) << std::endl
+ << iml2 << " = " << quantity<mil_length>(iml2) << std::endl
+ << iml3 << " = " << quantity<mil_length>(iml3) << std::endl
+ << iml4 << " = " << quantity<mil_length>(iml4) << std::endl
+ << iml5 << " = " << quantity<mil_length>(iml5) << std::endl
+ << std::endl;
+
+ std::cout << iml1 << " = " << quantity<inch_length>(iml1) << std::endl
+ << iml2 << " = " << quantity<inch_length>(iml2) << std::endl
+ << iml3 << " = " << quantity<inch_length>(iml3) << std::endl
+ << iml4 << " = " << quantity<inch_length>(iml4) << std::endl
+ << iml5 << " = " << quantity<inch_length>(iml5) << std::endl
+ << std::endl;
+
+ std::cout << iml1 << " = " << quantity<foot_length>(iml1) << std::endl
+ << iml2 << " = " << quantity<foot_length>(iml2) << std::endl
+ << iml3 << " = " << quantity<foot_length>(iml3) << std::endl
+ << iml4 << " = " << quantity<foot_length>(iml4) << std::endl
+ << iml5 << " = " << quantity<foot_length>(iml5) << std::endl
+ << std::endl;
+
+ std::cout << iml1 << " = " << quantity<yard_length>(iml1) << std::endl
+ << iml2 << " = " << quantity<yard_length>(iml2) << std::endl
+ << iml3 << " = " << quantity<yard_length>(iml3) << std::endl
+ << iml4 << " = " << quantity<yard_length>(iml4) << std::endl
+ << iml5 << " = " << quantity<yard_length>(iml5) << std::endl
+ << std::endl;
+
+ std::cout << iml1 << " = " << quantity<mile_length>(iml1) << std::endl
+ << iml2 << " = " << quantity<mile_length>(iml2) << std::endl
+ << iml3 << " = " << quantity<mile_length>(iml3) << std::endl
+ << iml4 << " = " << quantity<mile_length>(iml4) << std::endl
+ << iml5 << " = " << quantity<mile_length>(iml5) << std::endl
+ << std::endl;
+
+ quantity<grain_mass> imm1(1.0*grains);
+ quantity<dram_mass> imm2(1.0*drams);
+ quantity<ounce_mass> imm3(1.0*ounces);
+ quantity<pound_mass> imm4(1.0*pounds);
+ quantity<hundredweight_mass> imm5(1.0*hundredweights);
+ quantity<ton_mass> imm6(1.0*tons);
+
+ std::cout << imm1 << " = " << quantity<si::mass>(imm1) << std::endl
+ << imm2 << " = " << quantity<si::mass>(imm2) << std::endl
+ << imm3 << " = " << quantity<si::mass>(imm3) << std::endl
+ << imm4 << " = " << quantity<si::mass>(imm4) << std::endl
+ << imm5 << " = " << quantity<si::mass>(imm5) << std::endl
+ << imm6 << " = " << quantity<si::mass>(imm6) << std::endl
+ << std::endl;
+
+ std::cout << imm6 << "/" << imm1 << " = " << quantity<si::dimensionless>(imm6/imm1) << std::endl
+ << imm6 << "/" << imm2 << " = " << quantity<si::dimensionless>(imm6/imm2) << std::endl
+ << imm6 << "/" << imm3 << " = " << quantity<si::dimensionless>(imm6/imm3) << std::endl
+ << imm6 << "/" << imm4 << " = " << quantity<si::dimensionless>(imm6/imm4) << std::endl
+ << imm6 << "/" << imm5 << " = " << quantity<si::dimensionless>(imm6/imm5) << std::endl
+ << std::endl;
+
+ std::cout << imm1 << " = " << quantity<grain_mass>(imm1) << std::endl
+ << imm2 << " = " << quantity<grain_mass>(imm2) << std::endl
+ << imm3 << " = " << quantity<grain_mass>(imm3) << std::endl
+ << imm4 << " = " << quantity<grain_mass>(imm4) << std::endl
+ << imm5 << " = " << quantity<grain_mass>(imm5) << std::endl
+ << imm6 << " = " << quantity<grain_mass>(imm6) << std::endl
+ << std::endl;
+
+ std::cout << imm1 << " = " << quantity<dram_mass>(imm1) << std::endl
+ << imm2 << " = " << quantity<dram_mass>(imm2) << std::endl
+ << imm3 << " = " << quantity<dram_mass>(imm3) << std::endl
+ << imm4 << " = " << quantity<dram_mass>(imm4) << std::endl
+ << imm5 << " = " << quantity<dram_mass>(imm5) << std::endl
+ << imm6 << " = " << quantity<dram_mass>(imm6) << std::endl
+ << std::endl;
+
+ std::cout << imm1 << " = " << quantity<ounce_mass>(imm1) << std::endl
+ << imm2 << " = " << quantity<ounce_mass>(imm2) << std::endl
+ << imm3 << " = " << quantity<ounce_mass>(imm3) << std::endl
+ << imm4 << " = " << quantity<ounce_mass>(imm4) << std::endl
+ << imm5 << " = " << quantity<ounce_mass>(imm5) << std::endl
+ << imm6 << " = " << quantity<ounce_mass>(imm6) << std::endl
+ << std::endl;
+
+ std::cout << imm1 << " = " << quantity<pound_mass>(imm1) << std::endl
+ << imm2 << " = " << quantity<pound_mass>(imm2) << std::endl
+ << imm3 << " = " << quantity<pound_mass>(imm3) << std::endl
+ << imm4 << " = " << quantity<pound_mass>(imm4) << std::endl
+ << imm5 << " = " << quantity<pound_mass>(imm5) << std::endl
+ << imm6 << " = " << quantity<pound_mass>(imm6) << std::endl
+ << std::endl;
+
+ std::cout << imm1 << " = " << quantity<hundredweight_mass>(imm1) << std::endl
+ << imm2 << " = " << quantity<hundredweight_mass>(imm2) << std::endl
+ << imm3 << " = " << quantity<hundredweight_mass>(imm3) << std::endl
+ << imm4 << " = " << quantity<hundredweight_mass>(imm4) << std::endl
+ << imm5 << " = " << quantity<hundredweight_mass>(imm5) << std::endl
+ << imm6 << " = " << quantity<hundredweight_mass>(imm6) << std::endl
+ << std::endl;
+
+ std::cout << imm1 << " = " << quantity<ton_mass>(imm1) << std::endl
+ << imm2 << " = " << quantity<ton_mass>(imm2) << std::endl
+ << imm3 << " = " << quantity<ton_mass>(imm3) << std::endl
+ << imm4 << " = " << quantity<ton_mass>(imm4) << std::endl
+ << imm5 << " = " << quantity<ton_mass>(imm5) << std::endl
+ << imm6 << " = " << quantity<ton_mass>(imm6) << std::endl
+ << std::endl;
+
+ quantity<minim_volume> imv1(1.0*minims);
+ quantity<fluid_dram_volume> imv2(1.0*fluid_drams);
+ quantity<teaspoon_volume> imv3(1.0*teaspoons);
+ quantity<tablespoon_volume> imv4(1.0*tablespoons);
+ quantity<fluid_ounce_volume> imv5(1.0*fluid_ounces);
+ quantity<gill_volume> imv6(1.0*gills);
+ quantity<cup_volume> imv7(1.0*cups);
+ quantity<pint_volume> imv8(1.0*pints);
+ quantity<quart_volume> imv9(1.0*quarts);
+ quantity<gallon_volume> imv10(1.0*gallons);
+
+ std::cout << imv1 << " = " << quantity<si::volume>(imv1) << std::endl
+ << imv2 << " = " << quantity<si::volume>(imv2) << std::endl
+ << imv3 << " = " << quantity<si::volume>(imv3) << std::endl
+ << imv4 << " = " << quantity<si::volume>(imv4) << std::endl
+ << imv5 << " = " << quantity<si::volume>(imv5) << std::endl
+ << imv6 << " = " << quantity<si::volume>(imv6) << std::endl
+ << imv7 << " = " << quantity<si::volume>(imv7) << std::endl
+ << imv8 << " = " << quantity<si::volume>(imv8) << std::endl
+ << imv9 << " = " << quantity<si::volume>(imv9) << std::endl
+ << imv10 << " = " << quantity<si::volume>(imv10) << std::endl
+ << std::endl;
+
+ std::cout << imv10 << "/" << imv1 << " = " << quantity<si::dimensionless>(imv10/imv1) << std::endl
+ << imv10 << "/" << imv2 << " = " << quantity<si::dimensionless>(imv10/imv2) << std::endl
+ << imv10 << "/" << imv3 << " = " << quantity<si::dimensionless>(imv10/imv3) << std::endl
+ << imv10 << "/" << imv4 << " = " << quantity<si::dimensionless>(imv10/imv4) << std::endl
+ << imv10 << "/" << imv5 << " = " << quantity<si::dimensionless>(imv10/imv5) << std::endl
+ << imv10 << "/" << imv6 << " = " << quantity<si::dimensionless>(imv10/imv6) << std::endl
+ << imv10 << "/" << imv7 << " = " << quantity<si::dimensionless>(imv10/imv7) << std::endl
+ << imv10 << "/" << imv8 << " = " << quantity<si::dimensionless>(imv10/imv8) << std::endl
+ << imv10 << "/" << imv9 << " = " << quantity<si::dimensionless>(imv10/imv9) << std::endl
+ << std::endl;
+
+ std::cout << imv1 << " = " << quantity<minim_volume>(imv1) << std::endl
+ << imv2 << " = " << quantity<minim_volume>(imv2) << std::endl
+ << imv3 << " = " << quantity<minim_volume>(imv3) << std::endl
+ << imv4 << " = " << quantity<minim_volume>(imv4) << std::endl
+ << imv5 << " = " << quantity<minim_volume>(imv5) << std::endl
+ << imv6 << " = " << quantity<minim_volume>(imv6) << std::endl
+ << imv7 << " = " << quantity<minim_volume>(imv7) << std::endl
+ << imv8 << " = " << quantity<minim_volume>(imv8) << std::endl
+ << imv9 << " = " << quantity<minim_volume>(imv9) << std::endl
+ << imv10 << " = " << quantity<minim_volume>(imv10) << std::endl
+ << std::endl;
+
+ std::cout << imv1 << " = " << quantity<fluid_dram_volume>(imv1) << std::endl
+ << imv2 << " = " << quantity<fluid_dram_volume>(imv2) << std::endl
+ << imv3 << " = " << quantity<fluid_dram_volume>(imv3) << std::endl
+ << imv4 << " = " << quantity<fluid_dram_volume>(imv4) << std::endl
+ << imv5 << " = " << quantity<fluid_dram_volume>(imv5) << std::endl
+ << imv6 << " = " << quantity<fluid_dram_volume>(imv6) << std::endl
+ << imv7 << " = " << quantity<fluid_dram_volume>(imv7) << std::endl
+ << imv8 << " = " << quantity<fluid_dram_volume>(imv8) << std::endl
+ << imv9 << " = " << quantity<fluid_dram_volume>(imv9) << std::endl
+ << imv10 << " = " << quantity<fluid_dram_volume>(imv10) << std::endl
+ << std::endl;
+
+ std::cout << imv1 << " = " << quantity<teaspoon_volume>(imv1) << std::endl
+ << imv2 << " = " << quantity<teaspoon_volume>(imv2) << std::endl
+ << imv3 << " = " << quantity<teaspoon_volume>(imv3) << std::endl
+ << imv4 << " = " << quantity<teaspoon_volume>(imv4) << std::endl
+ << imv5 << " = " << quantity<teaspoon_volume>(imv5) << std::endl
+ << imv6 << " = " << quantity<teaspoon_volume>(imv6) << std::endl
+ << imv7 << " = " << quantity<teaspoon_volume>(imv7) << std::endl
+ << imv8 << " = " << quantity<teaspoon_volume>(imv8) << std::endl
+ << imv9 << " = " << quantity<teaspoon_volume>(imv9) << std::endl
+ << imv10 << " = " << quantity<teaspoon_volume>(imv10) << std::endl
+ << std::endl;
+
+ std::cout << imv1 << " = " << quantity<tablespoon_volume>(imv1) << std::endl
+ << imv2 << " = " << quantity<tablespoon_volume>(imv2) << std::endl
+ << imv3 << " = " << quantity<tablespoon_volume>(imv3) << std::endl
+ << imv4 << " = " << quantity<tablespoon_volume>(imv4) << std::endl
+ << imv5 << " = " << quantity<tablespoon_volume>(imv5) << std::endl
+ << imv6 << " = " << quantity<tablespoon_volume>(imv6) << std::endl
+ << imv7 << " = " << quantity<tablespoon_volume>(imv7) << std::endl
+ << imv8 << " = " << quantity<tablespoon_volume>(imv8) << std::endl
+ << imv9 << " = " << quantity<tablespoon_volume>(imv9) << std::endl
+ << imv10 << " = " << quantity<tablespoon_volume>(imv10) << std::endl
+ << std::endl;
+
+ std::cout << imv1 << " = " << quantity<fluid_ounce_volume>(imv1) << std::endl
+ << imv2 << " = " << quantity<fluid_ounce_volume>(imv2) << std::endl
+ << imv3 << " = " << quantity<fluid_ounce_volume>(imv3) << std::endl
+ << imv4 << " = " << quantity<fluid_ounce_volume>(imv4) << std::endl
+ << imv5 << " = " << quantity<fluid_ounce_volume>(imv5) << std::endl
+ << imv6 << " = " << quantity<fluid_ounce_volume>(imv6) << std::endl
+ << imv7 << " = " << quantity<fluid_ounce_volume>(imv7) << std::endl
+ << imv8 << " = " << quantity<fluid_ounce_volume>(imv8) << std::endl
+ << imv9 << " = " << quantity<fluid_ounce_volume>(imv9) << std::endl
+ << imv10 << " = " << quantity<fluid_ounce_volume>(imv10) << std::endl
+ << std::endl;
+
+ std::cout << imv1 << " = " << quantity<gill_volume>(imv1) << std::endl
+ << imv2 << " = " << quantity<gill_volume>(imv2) << std::endl
+ << imv3 << " = " << quantity<gill_volume>(imv3) << std::endl
+ << imv4 << " = " << quantity<gill_volume>(imv4) << std::endl
+ << imv5 << " = " << quantity<gill_volume>(imv5) << std::endl
+ << imv6 << " = " << quantity<gill_volume>(imv6) << std::endl
+ << imv7 << " = " << quantity<gill_volume>(imv7) << std::endl
+ << imv8 << " = " << quantity<gill_volume>(imv8) << std::endl
+ << imv9 << " = " << quantity<gill_volume>(imv9) << std::endl
+ << imv10 << " = " << quantity<gill_volume>(imv10) << std::endl
+ << std::endl;
+
+ std::cout << imv1 << " = " << quantity<cup_volume>(imv1) << std::endl
+ << imv2 << " = " << quantity<cup_volume>(imv2) << std::endl
+ << imv3 << " = " << quantity<cup_volume>(imv3) << std::endl
+ << imv4 << " = " << quantity<cup_volume>(imv4) << std::endl
+ << imv5 << " = " << quantity<cup_volume>(imv5) << std::endl
+ << imv6 << " = " << quantity<cup_volume>(imv6) << std::endl
+ << imv7 << " = " << quantity<cup_volume>(imv7) << std::endl
+ << imv8 << " = " << quantity<cup_volume>(imv8) << std::endl
+ << imv9 << " = " << quantity<cup_volume>(imv9) << std::endl
+ << imv10 << " = " << quantity<cup_volume>(imv10) << std::endl
+ << std::endl;
+
+ std::cout << imv1 << " = " << quantity<pint_volume>(imv1) << std::endl
+ << imv2 << " = " << quantity<pint_volume>(imv2) << std::endl
+ << imv3 << " = " << quantity<pint_volume>(imv3) << std::endl
+ << imv4 << " = " << quantity<pint_volume>(imv4) << std::endl
+ << imv5 << " = " << quantity<pint_volume>(imv5) << std::endl
+ << imv6 << " = " << quantity<pint_volume>(imv6) << std::endl
+ << imv7 << " = " << quantity<pint_volume>(imv7) << std::endl
+ << imv8 << " = " << quantity<pint_volume>(imv8) << std::endl
+ << imv9 << " = " << quantity<pint_volume>(imv9) << std::endl
+ << imv10 << " = " << quantity<pint_volume>(imv10) << std::endl
+ << std::endl;
+
+ std::cout << imv1 << " = " << quantity<quart_volume>(imv1) << std::endl
+ << imv2 << " = " << quantity<quart_volume>(imv2) << std::endl
+ << imv3 << " = " << quantity<quart_volume>(imv3) << std::endl
+ << imv4 << " = " << quantity<quart_volume>(imv4) << std::endl
+ << imv5 << " = " << quantity<quart_volume>(imv5) << std::endl
+ << imv6 << " = " << quantity<quart_volume>(imv6) << std::endl
+ << imv7 << " = " << quantity<quart_volume>(imv7) << std::endl
+ << imv8 << " = " << quantity<quart_volume>(imv8) << std::endl
+ << imv9 << " = " << quantity<quart_volume>(imv9) << std::endl
+ << imv10 << " = " << quantity<quart_volume>(imv10) << std::endl
+ << std::endl;
+
+ std::cout << imv1 << " = " << quantity<gallon_volume>(imv1) << std::endl
+ << imv2 << " = " << quantity<gallon_volume>(imv2) << std::endl
+ << imv3 << " = " << quantity<gallon_volume>(imv3) << std::endl
+ << imv4 << " = " << quantity<gallon_volume>(imv4) << std::endl
+ << imv5 << " = " << quantity<gallon_volume>(imv5) << std::endl
+ << imv6 << " = " << quantity<gallon_volume>(imv6) << std::endl
+ << imv7 << " = " << quantity<gallon_volume>(imv7) << std::endl
+ << imv8 << " = " << quantity<gallon_volume>(imv8) << std::endl
+ << imv9 << " = " << quantity<gallon_volume>(imv9) << std::endl
+ << imv10 << " = " << quantity<gallon_volume>(imv10) << std::endl
+ << std::endl;
+ }
+
+ return 0;
+}
diff --git a/src/boost/libs/units/example/temperature.cpp b/src/boost/libs/units/example/temperature.cpp
new file mode 100644
index 000000000..f6b434214
--- /dev/null
+++ b/src/boost/libs/units/example/temperature.cpp
@@ -0,0 +1,98 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2008 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)
+
+/**
+\file
+
+\brief temperature.cpp
+
+\details
+Conversions between Fahrenheit and Kelvin for absolute temperatures and
+temperature differences.
+
+Output:
+@verbatim
+
+//[ temperature_output_1
+{ 32 } F
+{ 273.15 } K
+{ 273.15 } K
+[ 32 ] F
+[ 17.7778 ] K
+[ 17.7778 ] K
+//]
+
+@endverbatim
+**/
+
+#include <iomanip>
+#include <iostream>
+
+#include <boost/units/absolute.hpp>
+#include <boost/units/get_system.hpp>
+#include <boost/units/io.hpp>
+#include <boost/units/unit.hpp>
+#include <boost/units/quantity.hpp>
+#include <boost/units/systems/si/temperature.hpp>
+#include <boost/units/detail/utility.hpp>
+
+#include <boost/units/base_units/temperature/fahrenheit.hpp>
+
+using namespace boost::units;
+
+namespace boost {
+
+namespace units {
+
+namespace fahrenheit {
+
+//[temperature_snippet_1
+typedef temperature::fahrenheit_base_unit::unit_type temperature;
+typedef get_system<temperature>::type system;
+
+BOOST_UNITS_STATIC_CONSTANT(degree,temperature);
+BOOST_UNITS_STATIC_CONSTANT(degrees,temperature);
+//]
+
+} // fahrenheit
+
+} // namespace units
+
+} // namespace boost
+
+int main()
+{
+ //[temperature_snippet_3
+ quantity<absolute<fahrenheit::temperature> > T1p(
+ 32.0*absolute<fahrenheit::temperature>());
+ quantity<fahrenheit::temperature> T1v(
+ 32.0*fahrenheit::degrees);
+
+ quantity<absolute<si::temperature> > T2p(T1p);
+ quantity<si::temperature> T2v(T1v);
+ //]
+
+ typedef conversion_helper<
+ quantity<absolute<fahrenheit::temperature> >,
+ quantity<absolute<si::temperature> > > absolute_conv_type;
+ typedef conversion_helper<
+ quantity<fahrenheit::temperature>,
+ quantity<si::temperature> > relative_conv_type;
+
+ std::cout << T1p << std::endl
+ << absolute_conv_type::convert(T1p) << std::endl
+ << T2p << std::endl
+ << T1v << std::endl
+ << relative_conv_type::convert(T1v) << std::endl
+ << T2v << std::endl
+ << std::endl;
+
+ return 0;
+}
diff --git a/src/boost/libs/units/example/test_system.hpp b/src/boost/libs/units/example/test_system.hpp
new file mode 100644
index 000000000..0eaaa9737
--- /dev/null
+++ b/src/boost/libs/units/example/test_system.hpp
@@ -0,0 +1,153 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2008 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)
+
+#ifndef MCS_TEST_SYSTEM_HPP
+#define MCS_TEST_SYSTEM_HPP
+
+#include <boost/mpl/list.hpp>
+#include <boost/mpl/vector.hpp>
+
+#include <boost/units/base_dimension.hpp>
+#include <boost/units/derived_dimension.hpp>
+#include <boost/units/io.hpp>
+#include <boost/units/quantity.hpp>
+#include <boost/units/static_constant.hpp>
+#include <boost/units/unit.hpp>
+#include <boost/units/base_unit.hpp>
+#include <boost/units/make_system.hpp>
+
+namespace boost {
+
+namespace units {
+
+//[test_system_snippet_1
+
+/// base dimension of length
+struct length_base_dimension : base_dimension<length_base_dimension,1> { };
+/// base dimension of mass
+struct mass_base_dimension : base_dimension<mass_base_dimension,2> { };
+/// base dimension of time
+struct time_base_dimension : base_dimension<time_base_dimension,3> { };
+
+//]
+
+#if 0
+//[test_system_snippet_2
+
+typedef make_dimension_list<
+ boost::mpl::list< dim< length_base_dimension,static_rational<1> > >
+>::type length_dimension;
+
+typedef make_dimension_list<
+ boost::mpl::list< dim< mass_base_dimension,static_rational<1> > >
+>::type mass_dimension;
+
+typedef make_dimension_list<
+ boost::mpl::list< dim< time_base_dimension,static_rational<1> > >
+>::type time_dimension;
+
+//]
+#endif
+
+//[test_system_snippet_3
+typedef length_base_dimension::dimension_type length_dimension;
+typedef mass_base_dimension::dimension_type mass_dimension;
+typedef time_base_dimension::dimension_type time_dimension;
+//]
+
+#if 0
+//[test_system_snippet_4
+
+typedef make_dimension_list<
+ boost::mpl::list< dim< length_base_dimension,static_rational<2> > >
+>::type area_dimension;
+
+typedef make_dimension_list<
+ boost::mpl::list< dim< mass_base_dimension,static_rational<1> >,
+ dim< length_base_dimension,static_rational<2> >,
+ dim< time_base_dimension,static_rational<-2> > >
+>::type energy_dimension;
+
+//]
+#endif
+
+//[test_system_snippet_5
+typedef derived_dimension<length_base_dimension,2>::type area_dimension;
+typedef derived_dimension<mass_base_dimension,1,
+ length_base_dimension,2,
+ time_base_dimension,-2>::type energy_dimension;
+//]
+
+namespace test {
+
+//[test_system_snippet_6
+
+struct meter_base_unit : base_unit<meter_base_unit, length_dimension, 1> { };
+struct kilogram_base_unit : base_unit<kilogram_base_unit, mass_dimension, 2> { };
+struct second_base_unit : base_unit<second_base_unit, time_dimension, 3> { };
+
+typedef make_system<
+ meter_base_unit,
+ kilogram_base_unit,
+ second_base_unit>::type mks_system;
+
+/// unit typedefs
+typedef unit<dimensionless_type,mks_system> dimensionless;
+
+typedef unit<length_dimension,mks_system> length;
+typedef unit<mass_dimension,mks_system> mass;
+typedef unit<time_dimension,mks_system> time;
+
+typedef unit<area_dimension,mks_system> area;
+typedef unit<energy_dimension,mks_system> energy;
+//]
+
+//[test_system_snippet_7
+/// unit constants
+BOOST_UNITS_STATIC_CONSTANT(meter,length);
+BOOST_UNITS_STATIC_CONSTANT(meters,length);
+BOOST_UNITS_STATIC_CONSTANT(kilogram,mass);
+BOOST_UNITS_STATIC_CONSTANT(kilograms,mass);
+BOOST_UNITS_STATIC_CONSTANT(second,time);
+BOOST_UNITS_STATIC_CONSTANT(seconds,time);
+
+BOOST_UNITS_STATIC_CONSTANT(square_meter,area);
+BOOST_UNITS_STATIC_CONSTANT(square_meters,area);
+BOOST_UNITS_STATIC_CONSTANT(joule,energy);
+BOOST_UNITS_STATIC_CONSTANT(joules,energy);
+//]
+
+} // namespace test
+
+//[test_system_snippet_8
+template<> struct base_unit_info<test::meter_base_unit>
+{
+ static std::string name() { return "meter"; }
+ static std::string symbol() { return "m"; }
+};
+//]
+
+template<> struct base_unit_info<test::kilogram_base_unit>
+{
+ static std::string name() { return "kilogram"; }
+ static std::string symbol() { return "kg"; }
+};
+
+template<> struct base_unit_info<test::second_base_unit>
+{
+ static std::string name() { return "second"; }
+ static std::string symbol() { return "s"; }
+};
+
+} // namespace units
+
+} // namespace boost
+
+#endif // MCS_TEST_SYSTEM_HPP
diff --git a/src/boost/libs/units/example/tutorial.cpp b/src/boost/libs/units/example/tutorial.cpp
new file mode 100644
index 000000000..acda5ee94
--- /dev/null
+++ b/src/boost/libs/units/example/tutorial.cpp
@@ -0,0 +1,95 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2008 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)
+
+/**
+\file tutorial.cpp
+
+\brief Basic tutorial using SI units.
+
+\details
+Tutorial
+Defines a function that computes the work, in joules,
+done by exerting a force in newtons over a specified distance
+in meters and outputs the result to std::cout.
+
+Also code for computing the complex impedance
+using std::complex<double> as the value type.
+
+Output:
+@verbatim
+//[tutorial_output
+F = 2 N
+dx = 2 m
+E = 4 J
+
+V = (12.5,0) V
+I = (3,4) A
+Z = (1.5,-2) Ohm
+I*Z = (12.5,0) V
+I*Z == V? true
+//]
+@endverbatim
+*/
+
+//[tutorial_code
+#include <complex>
+#include <iostream>
+
+#include <boost/typeof/std/complex.hpp>
+
+#include <boost/units/systems/si/energy.hpp>
+#include <boost/units/systems/si/force.hpp>
+#include <boost/units/systems/si/length.hpp>
+#include <boost/units/systems/si/electric_potential.hpp>
+#include <boost/units/systems/si/current.hpp>
+#include <boost/units/systems/si/resistance.hpp>
+#include <boost/units/systems/si/io.hpp>
+
+using namespace boost::units;
+using namespace boost::units::si;
+
+constexpr
+quantity<energy>
+work(const quantity<force>& F, const quantity<length>& dx)
+{
+ return F * dx; // Defines the relation: work = force * distance.
+}
+
+int main()
+{
+ /// Test calculation of work.
+ quantity<force> F(2.0 * newton); // Define a quantity of force.
+ quantity<length> dx(2.0 * meter); // and a distance,
+ quantity<energy> E(work(F,dx)); // and calculate the work done.
+
+ std::cout << "F = " << F << std::endl
+ << "dx = " << dx << std::endl
+ << "E = " << E << std::endl
+ << std::endl;
+
+ /// Test and check complex quantities.
+ typedef std::complex<double> complex_type; // double real and imaginary parts.
+
+ // Define some complex electrical quantities.
+ quantity<electric_potential, complex_type> v = complex_type(12.5, 0.0) * volts;
+ quantity<current, complex_type> i = complex_type(3.0, 4.0) * amperes;
+ quantity<resistance, complex_type> z = complex_type(1.5, -2.0) * ohms;
+
+ std::cout << "V = " << v << std::endl
+ << "I = " << i << std::endl
+ << "Z = " << z << std::endl
+ // Calculate from Ohm's law voltage = current * resistance.
+ << "I * Z = " << i * z << std::endl
+ // Check defined V is equal to calculated.
+ << "I * Z == V? " << std::boolalpha << (i * z == v) << std::endl
+ << std::endl;
+ return 0;
+}
+//]
diff --git a/src/boost/libs/units/example/unit.cpp b/src/boost/libs/units/example/unit.cpp
new file mode 100644
index 000000000..934d55733
--- /dev/null
+++ b/src/boost/libs/units/example/unit.cpp
@@ -0,0 +1,73 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2008 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)
+
+/**
+\file
+
+\brief unit.cpp
+
+\details
+Test unit algebra.
+
+Output:
+@verbatim
+
+//[unit_output
+L = m
+L+L = m
+L-L = m
+L/L = dimensionless
+meter*meter = m^2
+M*(L/T)*(L/T) = m^2 kg s^-2
+M*(L/T)^2 = m^2 kg s^-2
+L^3 = m^3
+L^(3/2) = m^(3/2)
+2vM = kg^(1/2)
+(3/2)vM = kg^(2/3)
+//]
+
+@endverbatim
+**/
+
+#include <iostream>
+
+#include "test_system.hpp"
+
+#include <boost/units/pow.hpp>
+
+int main()
+{
+ using namespace boost::units;
+ using namespace boost::units::test;
+
+ //[unit_snippet_1
+ const length L;
+ const mass M;
+ // needs to be namespace-qualified because of global time definition
+ const boost::units::test::time T;
+ const energy E;
+ //]
+
+ std::cout << "L = " << L << std::endl
+ << "L+L = " << L+L << std::endl
+ << "L-L = " << L-L << std::endl
+ << "L/L = " << L/L << std::endl
+ << "meter*meter = " << meter*meter << std::endl
+ << "M*(L/T)*(L/T) = " << M*(L/T)*(L/T) << std::endl
+ << "M*(L/T)^2 = " << M*pow<2>(L/T) << std::endl
+ << "L^3 = " << pow<3>(L) << std::endl
+ << "L^(3/2) = " << pow<static_rational<3,2> >(L)
+ << std::endl
+ << "2vM = " << root<2>(M) << std::endl
+ << "(3/2)vM = " << root<static_rational<3,2> >(M)
+ << std::endl;
+
+ return 0;
+}
diff --git a/src/boost/libs/units/images/form_0.png b/src/boost/libs/units/images/form_0.png
new file mode 100644
index 000000000..7a8b61e2b
--- /dev/null
+++ b/src/boost/libs/units/images/form_0.png
Binary files differ
diff --git a/src/boost/libs/units/images/form_1.png b/src/boost/libs/units/images/form_1.png
new file mode 100644
index 000000000..aa6ec9143
--- /dev/null
+++ b/src/boost/libs/units/images/form_1.png
Binary files differ
diff --git a/src/boost/libs/units/images/form_10.png b/src/boost/libs/units/images/form_10.png
new file mode 100644
index 000000000..debfc1d77
--- /dev/null
+++ b/src/boost/libs/units/images/form_10.png
Binary files differ
diff --git a/src/boost/libs/units/images/form_11.png b/src/boost/libs/units/images/form_11.png
new file mode 100644
index 000000000..867920440
--- /dev/null
+++ b/src/boost/libs/units/images/form_11.png
Binary files differ
diff --git a/src/boost/libs/units/images/form_12.png b/src/boost/libs/units/images/form_12.png
new file mode 100644
index 000000000..1e92526b3
--- /dev/null
+++ b/src/boost/libs/units/images/form_12.png
Binary files differ
diff --git a/src/boost/libs/units/images/form_13.png b/src/boost/libs/units/images/form_13.png
new file mode 100644
index 000000000..d4fe57249
--- /dev/null
+++ b/src/boost/libs/units/images/form_13.png
Binary files differ
diff --git a/src/boost/libs/units/images/form_14.png b/src/boost/libs/units/images/form_14.png
new file mode 100644
index 000000000..8e2e28232
--- /dev/null
+++ b/src/boost/libs/units/images/form_14.png
Binary files differ
diff --git a/src/boost/libs/units/images/form_15.png b/src/boost/libs/units/images/form_15.png
new file mode 100644
index 000000000..ef47182bd
--- /dev/null
+++ b/src/boost/libs/units/images/form_15.png
Binary files differ
diff --git a/src/boost/libs/units/images/form_2.png b/src/boost/libs/units/images/form_2.png
new file mode 100644
index 000000000..06bb0ec08
--- /dev/null
+++ b/src/boost/libs/units/images/form_2.png
Binary files differ
diff --git a/src/boost/libs/units/images/form_3.png b/src/boost/libs/units/images/form_3.png
new file mode 100644
index 000000000..5a59744e2
--- /dev/null
+++ b/src/boost/libs/units/images/form_3.png
Binary files differ
diff --git a/src/boost/libs/units/images/form_4.png b/src/boost/libs/units/images/form_4.png
new file mode 100644
index 000000000..4b1c9b2d7
--- /dev/null
+++ b/src/boost/libs/units/images/form_4.png
Binary files differ
diff --git a/src/boost/libs/units/images/form_5.png b/src/boost/libs/units/images/form_5.png
new file mode 100644
index 000000000..a641eb61c
--- /dev/null
+++ b/src/boost/libs/units/images/form_5.png
Binary files differ
diff --git a/src/boost/libs/units/images/form_6.png b/src/boost/libs/units/images/form_6.png
new file mode 100644
index 000000000..0075f7afa
--- /dev/null
+++ b/src/boost/libs/units/images/form_6.png
Binary files differ
diff --git a/src/boost/libs/units/images/form_7.png b/src/boost/libs/units/images/form_7.png
new file mode 100644
index 000000000..66b89ac5e
--- /dev/null
+++ b/src/boost/libs/units/images/form_7.png
Binary files differ
diff --git a/src/boost/libs/units/images/form_8.png b/src/boost/libs/units/images/form_8.png
new file mode 100644
index 000000000..f272bead7
--- /dev/null
+++ b/src/boost/libs/units/images/form_8.png
Binary files differ
diff --git a/src/boost/libs/units/images/form_9.png b/src/boost/libs/units/images/form_9.png
new file mode 100644
index 000000000..cbf21704b
--- /dev/null
+++ b/src/boost/libs/units/images/form_9.png
Binary files differ
diff --git a/src/boost/libs/units/index.html b/src/boost/libs/units/index.html
new file mode 100644
index 000000000..d03ad5c7b
--- /dev/null
+++ b/src/boost/libs/units/index.html
@@ -0,0 +1,22 @@
+<html>
+<head>
+<meta http-equiv="refresh" content="0; URL=../../doc/html/boost_units.html">
+</head>
+<body>
+Automatic redirection failed, please go to
+<a href="../../doc/html/boost_units.html">../../doc/html/boost_units.html</a>
+<hr>
+<tt>
+Boost.Units - A C++ library for zero-overhead dimensional analysis and
+unit/quantity manipulation and conversion <br>
+<br>
+Copyright (C) 2003-2008 Matthias Christian Schabel <br>
+Copyright (C) 2007-2008 Steven Watanabe <br>
+<br>
+Distributed under the Boost Software License, Version 1.0. (See
+accompanying file LICENSE_1_0.txt or copy at
+<a href=http://www.boost.org/LICENSE_1_0.txt>http://www.boost.org/LICENSE_1_0.txt</a>) <br>
+<br>
+</tt>
+</body>
+</html>
diff --git a/src/boost/libs/units/meta/libraries.json b/src/boost/libs/units/meta/libraries.json
new file mode 100644
index 000000000..4e8bdb9ad
--- /dev/null
+++ b/src/boost/libs/units/meta/libraries.json
@@ -0,0 +1,16 @@
+{
+ "key": "units",
+ "name": "Units",
+ "authors": [
+ "Matthias Schabel",
+ "Steven Watanabe"
+ ],
+ "description": "Zero-overhead dimensional analysis and unit/quantity manipulation and conversion.",
+ "category": [
+ "Domain"
+ ],
+ "maintainers": [
+ "Jürgen Hunold <jhunold -at- gmx.eu>",
+ "Steven Watanabe <steven -at- providere-consulting.com>"
+ ]
+}
diff --git a/src/boost/libs/units/test/Jamfile.v2 b/src/boost/libs/units/test/Jamfile.v2
new file mode 100644
index 000000000..5dae55621
--- /dev/null
+++ b/src/boost/libs/units/test/Jamfile.v2
@@ -0,0 +1,78 @@
+# Jamfile.v2
+#
+# Copyright (c) 2007-2009
+# 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
+
+import testing ;
+
+warning-options = <warnings>all <warnings-as-errors>on ;
+warning-compilers =
+ <toolset>msvc
+;
+
+project boost/units/test :
+ requirements
+ <implicit-dependency>/boost//headers
+ <toolset>msvc:<asynch-exceptions>on
+ $(warning-compilers)\:$(warning-options)
+ # This warning comes from the test library.
+ <toolset>msvc:<cxxflags>"/wd4701"
+ # The comes from the exception library
+ <toolset>msvc,<toolset-msvc:version>7.1:<cxxflags>"/wd4800"
+;
+
+alias test_framework : /boost//unit_test_framework/<warnings-as-errors>off ;
+
+compile test_predicates.cpp ;
+compile test_negative_denominator.cpp ;
+compile test_dimensionless_ice1.cpp ;
+compile test_dimensionless_ice2.cpp ;
+compile test_mixed_value_types.cpp ;
+compile test_complicated_system.cpp ;
+compile test_reduce_unit.cpp ;
+compile test_unscale.cpp ;
+compile test_constants.cpp ;
+
+run test_dimensionless_quantity.cpp ;
+run test_implicit_conversion.cpp ;
+run test_quantity.cpp ;
+run test_unit.cpp ;
+run test_conversion.cpp test_framework ;
+run test_base_dimension.cpp ;
+run test_absolute.cpp ;
+run test_default_conversion.cpp ;
+run test_cmath.cpp ;
+run test_limits.cpp ;
+run test_custom_unit.cpp ;
+run test_scaled_conversion.cpp ;
+run test_lambda.cpp ;
+run test_sqrt_scaled_unit.cpp ;
+run test_scaled_unit.cpp test_framework ;
+run test_output.cpp test_framework /boost//regex/<warnings-as-errors>off : : : <test-info>always_show_run_output ;
+run test_trig.cpp test_framework ;
+run test_information_units.cpp test_framework ;
+
+compile-fail fail_implicit_conversion.cpp ;
+compile-fail fail_quantity_construct.cpp ;
+compile-fail fail_quantity_assign.cpp ;
+compile-fail fail_quantity_add.cpp ;
+compile-fail fail_quantity_subtract.cpp ;
+compile-fail fail_quantity_add_assign.cpp ;
+compile-fail fail_quantity_sub_assign.cpp ;
+compile-fail fail_quantity_scalar_add.cpp ;
+compile-fail fail_quantity_scalar_sub.cpp ;
+compile-fail fail_quantity_unit_add.cpp ;
+compile-fail fail_quantity_unit_subtract.cpp ;
+compile-fail fail_scalar_quantity_add.cpp ;
+compile-fail fail_scalar_quantity_sub.cpp ;
+compile-fail fail_unit_quantity_add.cpp ;
+compile-fail fail_unit_quantity_subtract.cpp ;
+compile-fail fail_adl_detail.cpp ;
+compile-fail fail_heterogeneous_unit.cpp ;
+compile-fail fail_base_dimension.cpp ;
+compile-fail fail_add_temperature.cpp ;
+compile-fail fail_quantity_non_unit.cpp ;
diff --git a/src/boost/libs/units/test/check_conversion_defs.cpp b/src/boost/libs/units/test/check_conversion_defs.cpp
new file mode 100644
index 000000000..cb7ff56ba
--- /dev/null
+++ b/src/boost/libs/units/test/check_conversion_defs.cpp
@@ -0,0 +1,159 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2007-2008 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)
+
+#include <iterator>
+#include <string>
+#include <utility>
+#include <set>
+#include <map>
+#include <iostream>
+
+#include <boost/filesystem.hpp>
+#include <boost/filesystem/fstream.hpp>
+#include <boost/regex.hpp>
+
+namespace filesystem = boost::filesystem;
+
+//struct stop {
+// stop() { char c; std::cin >> c; }
+//} stop_;
+
+boost::regex whitespace("\\s*");
+boost::regex blank_line("\\A(?://.*$|\\s)*");
+
+boost::regex include_guard("#ifndef (\\w+)\n#define \\1\n");
+boost::regex base_unit("(\\w*_base_unit)(?:;| :)");
+
+std::pair<std::string, std::string> get_base_unit_and_include_guard(const filesystem::path& path) {
+ filesystem::ifstream in(path);
+ std::string contents(std::istreambuf_iterator<char>(in.rdbuf()), std::istreambuf_iterator<char>());
+ in.close();
+ boost::smatch include_guard_match;
+ boost::regex_search(contents, include_guard_match, include_guard);
+ boost::smatch base_unit_match;
+ boost::regex_search(contents, base_unit_match, base_unit);
+ std::cout << "creating map entry: " << base_unit_match[1].str() << " -> "<< include_guard_match[1].str() << std::endl;
+ return(std::make_pair(base_unit_match[1].str(), include_guard_match[1].str()));
+}
+
+int main() {
+ std::cout << "In main" << std::endl;
+ std::map<std::string, std::string> include_guards;
+ for(filesystem::directory_iterator begin(filesystem::path("../../../boost/units/systems/base_units")), end; begin != end; ++begin) {
+ if(begin->status().type() == filesystem::regular_file) {
+ std::cout << "reading file: " << begin->path() << std::endl;
+ include_guards.insert(get_base_unit_and_include_guard(begin->path()));
+ }
+ }
+
+ std::cout << "reading conversions file" << std::endl;
+ filesystem::ifstream conversions_file(filesystem::path("../../../boost/units/systems/base_units/detail/conversions.hpp"));
+
+ std::string line;
+ int line_count = 0;
+
+ boost::smatch match;
+
+ std::set<std::string> conversion_guards;
+
+ try {
+
+boost::regex include_guard_regex("#if defined\\((\\w+)\\) && defined\\((\\w+)\\) &&\\\\");
+std::cout << __LINE__ << std::endl;
+boost::regex conversion_guard_regex(" !defined\\((\\w+)\\)");
+std::cout << __LINE__ << std::endl;
+boost::regex set_conversion_guard(" #define (\\w+)");
+std::cout << __LINE__ << std::endl;
+boost::regex include_conversion(" #include <boost/units/conversion.hpp>");
+std::cout << __LINE__ << std::endl;
+boost::regex include_absolute(" #include <boost/units/absolute.hpp>");
+std::cout << __LINE__ << std::endl;
+boost::regex define_conversion_factor(" BOOST_UNITS_DEFINE_CONVERSION_FACTOR\\(boost::units::(\\w+_base_unit), boost::units::(\\w+_base_unit), \\w+, (?:[\\d\\.e\\-/ ]*|one\\(\\))\\);");
+std::cout << __LINE__ << std::endl;
+boost::regex define_conversion_offset(" BOOST_UNITS_DEFINE_CONVERSION_OFFSET\\(boost::units::(\\w+_base_unit), boost::units::(\\w+_base_unit), \\w+, [\\d\\.e+\\* \\-/]*\\);");
+std::cout << __LINE__ << std::endl;
+boost::regex endif("#endif");
+std::cout << __LINE__ << std::endl;
+
+ while(std::getline(conversions_file, line)) {
+ ++line_count;
+ std::cout << "on line: " << line_count << std::endl;
+ if(boost::regex_match(line, match, blank_line)) {
+ continue;
+ } else if(boost::regex_match(line, match, include_guard_regex)) {
+ std::string guard1, guard2, unit1, unit2, conversion_guard;
+ bool uses_absolute = false;
+
+ guard1 = match[1].str();
+ guard2 = match[2].str();
+ if(!std::getline(conversions_file, line)) { std::cerr << "unexpected end of file." << std::endl; return(1); } ++line_count;
+ if(!boost::regex_match(line, match, conversion_guard_regex)) { std::cerr << "error on line: " << line_count << std::endl; return(1); }
+
+ conversion_guard = match[1].str();
+ if(!conversion_guards.insert(conversion_guard).second){ std::cerr << "error on line: " << line_count << std::endl; return(1); }
+
+ if(!std::getline(conversions_file, line)) { std::cerr << "unexpected end of file." << std::endl; return(1); } ++line_count;
+ if(!boost::regex_match(line, match, set_conversion_guard)) { std::cerr << "error on line: " << line_count << std::endl; return(1); }
+std::cout << __LINE__ << std::endl;
+
+ if(match[1].str() != conversion_guard) { std::cerr << "error on line: " << line_count << std::endl; return(1); }
+
+ if(!std::getline(conversions_file, line)) { std::cerr << "unexpected end of file." << std::endl; return(1); } ++line_count;
+ if(!boost::regex_match(line, match, include_conversion)) { std::cerr << "error on line: " << line_count << std::endl; return(1); }
+std::cout << __LINE__ << std::endl;
+
+ if(!std::getline(conversions_file, line)) { std::cerr << "unexpected end of file." << std::endl; return(1); } ++line_count;
+ if(boost::regex_match(line, match, include_absolute)) {
+ uses_absolute = true;
+ if(!std::getline(conversions_file, line)) { std::cerr << "unexpected end of file." << std::endl; return(1); } ++line_count;
+ }
+
+std::cout << __LINE__ << std::endl;
+ if(!boost::regex_match(line, match, define_conversion_factor)) { std::cerr << "error on line: " << line_count << std::endl; return(1); }
+
+std::cout << __LINE__ << ": " << line << std::endl;
+ unit1 = match[1].str();
+ unit2 = match[2].str();
+ if(!((include_guards[unit1] == guard1 && include_guards[unit2] == guard2) ||
+ (include_guards[unit1] == guard2 && include_guards[unit2] == guard1))) {
+ std::cerr << "guard1: " << guard1 << std::endl;
+ std::cerr << "guard2: " << guard2 << std::endl;
+ std::cerr << "unit1: " << unit1 << std::endl;
+ std::cerr << "unit2: " << unit2 << std::endl;
+ std::cerr << "include_guards[unit1]: " << include_guards[unit1] << std::endl;
+ std::cerr << "include_guards[unit2]: " << include_guards[unit2] << std::endl;
+ { std::cerr << "error on line: " << line_count << std::endl; return(1); }
+ }
+std::cout << __LINE__ << std::endl;
+
+ if(!std::getline(conversions_file, line)) { std::cerr << "unexpected end of file." << std::endl; return(1); } ++line_count;
+std::cout << __LINE__ << std::endl;
+ if(boost::regex_match(line, match, define_conversion_offset)) {
+ if(!uses_absolute) { std::cerr << "error on line: " << line_count << std::endl; return(1); }
+std::cout << __LINE__ << std::endl;
+ if(match[1].str() != unit1 || match[2].str() != unit2) { std::cerr << "error on line: " << line_count << std::endl; return(1); }
+ if(!std::getline(conversions_file, line)) { std::cerr << "unexpected end of file." << std::endl; return(1); } ++line_count;
+ } else {
+ if(uses_absolute) { std::cerr << "error on line: " << line_count << std::endl; return(1); }
+ }
+std::cout << __LINE__ << std::endl;
+
+
+ if(!boost::regex_match(line, match, endif)) { std::cerr << "error on line: " << line_count << std::endl; return(1); }
+
+ }
+ }
+
+ } catch(std::exception& e) {
+ std::cerr << e.what() << std::endl;
+ return(1);
+ }
+
+}
diff --git a/src/boost/libs/units/test/fail_add_temperature.cpp b/src/boost/libs/units/test/fail_add_temperature.cpp
new file mode 100644
index 000000000..979b23633
--- /dev/null
+++ b/src/boost/libs/units/test/fail_add_temperature.cpp
@@ -0,0 +1,38 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2008 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)
+
+/**
+\file
+
+\brief fail_add_temperature.cpp
+
+\details
+Verify that adding two absolute temeratures fails miserably.
+
+Output:
+@verbatim
+@endverbatim
+**/
+
+#include <boost/units/quantity.hpp>
+#include <boost/units/absolute.hpp>
+#include <boost/units/systems/si/temperature.hpp>
+
+namespace bu = boost::units;
+
+int main(int,char *[])
+{
+
+ bu::quantity<bu::absolute<bu::si::temperature> > q(2.0 * bu::absolute<bu::si::temperature>());
+
+ q += q;
+
+ return 0;
+}
diff --git a/src/boost/libs/units/test/fail_adl_detail.cpp b/src/boost/libs/units/test/fail_adl_detail.cpp
new file mode 100644
index 000000000..b44788df9
--- /dev/null
+++ b/src/boost/libs/units/test/fail_adl_detail.cpp
@@ -0,0 +1,48 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2008 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)
+
+/**
+\file
+
+\brief fail_adl_detail.cpp
+
+\details
+make sure that namespace detail is not pulled in by ADL.
+
+Output:
+@verbatim
+@endverbatim
+**/
+
+#include <boost/units/quantity.hpp>
+#include <boost/units/systems/si.hpp>
+
+namespace bu = boost::units;
+
+namespace boost {
+namespace units {
+namespace detail {
+
+ template<class T>
+ void this_function_should_not_be_found_by_adl(const T&) {};
+
+}
+}
+}
+
+int main(int argc,char *argv[])
+{
+
+ bu::quantity<bu::si::energy> q;
+
+ this_function_should_not_be_found_by_adl(q);
+
+ return 0;
+}
diff --git a/src/boost/libs/units/test/fail_base_dimension.cpp b/src/boost/libs/units/test/fail_base_dimension.cpp
new file mode 100644
index 000000000..1dd7a4a04
--- /dev/null
+++ b/src/boost/libs/units/test/fail_base_dimension.cpp
@@ -0,0 +1,32 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2008 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)
+
+/**
+\file
+
+\brief fail_base_dimension.cpp
+
+\details
+make sure that trying to use the same ordinal for multiple
+base dimensions fails.
+
+Output:
+@verbatim
+@endverbatim
+**/
+
+#include <boost/units/base_dimension.hpp>
+
+struct dim1 : boost::units::base_dimension<dim1, 1> {};
+struct dim2 : boost::units::base_dimension<dim2, 1> {};
+
+int main()
+{
+}
diff --git a/src/boost/libs/units/test/fail_heterogeneous_unit.cpp b/src/boost/libs/units/test/fail_heterogeneous_unit.cpp
new file mode 100644
index 000000000..c0f7692e6
--- /dev/null
+++ b/src/boost/libs/units/test/fail_heterogeneous_unit.cpp
@@ -0,0 +1,46 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2008 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)
+
+/**
+\file
+
+\brief fail_heterogeneous_unit.cpp
+
+\details
+make sure that trying to bind a heterogeneous system to a different dimension fails.
+
+Output:
+@verbatim
+@endverbatim
+**/
+
+#include <boost/units/pow.hpp>
+#include <boost/units/quantity.hpp>
+#include <boost/units/systems/si.hpp>
+#include <boost/units/systems/cgs.hpp>
+//#include <boost/units/systems/conversions/convert_cgs_to_si.hpp>
+//#include <boost/units/systems/conversions/convert_si_to_cgs.hpp>
+
+namespace bu = boost::units;
+
+template<class System>
+bu::quantity<bu::unit<bu::energy_dimension, System> > f(bu::quantity<bu::unit<bu::length_dimension, System> > l) {
+ return(static_cast<bu::quantity<bu::unit<bu::energy_dimension, System> > >(f(static_cast<bu::quantity<bu::si::length> >(l))));
+}
+bu::quantity<bu::si::energy> f(bu::quantity<bu::si::length> l) {
+ return(l * l * 2.0 * bu::si::kilograms / bu::pow<2>(bu::si::seconds));
+}
+
+int main() {
+
+ f(1.0 * bu::pow<2>(bu::si::meters) / bu::cgs::centimeters);
+
+ return(0);
+}
diff --git a/src/boost/libs/units/test/fail_implicit_conversion.cpp b/src/boost/libs/units/test/fail_implicit_conversion.cpp
new file mode 100644
index 000000000..bedef1b57
--- /dev/null
+++ b/src/boost/libs/units/test/fail_implicit_conversion.cpp
@@ -0,0 +1,36 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2008 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)
+
+/**
+\file
+
+\brief fail_implicit_conversion.cpp
+
+\details
+Test implicit conversions for quantity.
+
+Output:
+@verbatim
+@endverbatim
+**/
+
+#include <boost/units/quantity.hpp>
+#include <boost/units/systems/si.hpp>
+#include <boost/units/systems/cgs.hpp>
+
+namespace bu = boost::units;
+
+int main(int,char *[])
+{
+ const bu::quantity<bu::si::length> T1(2.0 * bu::si::meters);
+ const bu::quantity<bu::cgs::length> T2 = T1;
+
+ return 0;
+}
diff --git a/src/boost/libs/units/test/fail_quantity_add.cpp b/src/boost/libs/units/test/fail_quantity_add.cpp
new file mode 100644
index 000000000..e7e37d488
--- /dev/null
+++ b/src/boost/libs/units/test/fail_quantity_add.cpp
@@ -0,0 +1,35 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2008 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)
+
+/**
+\file
+
+\brief fail_quantity_add.cpp
+
+\details
+Test addition of quantities with different dimensions.
+
+Output:
+@verbatim
+@endverbatim
+**/
+
+#include <boost/units/quantity.hpp>
+#include <boost/units/systems/si.hpp>
+
+namespace bu = boost::units;
+
+int main(int argc,char *argv[])
+{
+
+ 2.0 * bu::si::seconds + 2.0 * bu::si::meters;
+
+ return 0;
+}
diff --git a/src/boost/libs/units/test/fail_quantity_add_assign.cpp b/src/boost/libs/units/test/fail_quantity_add_assign.cpp
new file mode 100644
index 000000000..f31df6150
--- /dev/null
+++ b/src/boost/libs/units/test/fail_quantity_add_assign.cpp
@@ -0,0 +1,36 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2008 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)
+
+/**
+\file
+
+\brief fail_quantity_add_assign.cpp
+
+\details
+Test += of quantity from different dimensions.
+
+Output:
+@verbatim
+@endverbatim
+**/
+
+#include <boost/units/quantity.hpp>
+#include <boost/units/systems/si.hpp>
+
+namespace bu = boost::units;
+
+int main(int,char *[])
+{
+
+ bu::quantity<bu::si::length> T1;
+ T1 += 2.0 * bu::si::seconds;
+
+ return 0;
+}
diff --git a/src/boost/libs/units/test/fail_quantity_assign.cpp b/src/boost/libs/units/test/fail_quantity_assign.cpp
new file mode 100644
index 000000000..0f48bf211
--- /dev/null
+++ b/src/boost/libs/units/test/fail_quantity_assign.cpp
@@ -0,0 +1,36 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2008 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)
+
+/**
+\file
+
+\brief fail_quantity_assign.cpp
+
+\details
+Test assignment of quantity from different dimensions.
+
+Output:
+@verbatim
+@endverbatim
+**/
+
+#include <boost/units/quantity.hpp>
+#include <boost/units/systems/si.hpp>
+
+namespace bu = boost::units;
+
+int main(int argc,char *argv[])
+{
+
+ const bu::quantity<bu::si::length> T1;
+ T1 = 2.0 * bu::si::seconds;
+
+ return 0;
+}
diff --git a/src/boost/libs/units/test/fail_quantity_construct.cpp b/src/boost/libs/units/test/fail_quantity_construct.cpp
new file mode 100644
index 000000000..945065834
--- /dev/null
+++ b/src/boost/libs/units/test/fail_quantity_construct.cpp
@@ -0,0 +1,35 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2008 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)
+
+/**
+\file
+
+\brief fail_quantity_construct.cpp
+
+\details
+Test construction of quantity from different dimensions.
+
+Output:
+@verbatim
+@endverbatim
+**/
+
+#include <boost/units/quantity.hpp>
+#include <boost/units/systems/si.hpp>
+
+namespace bu = boost::units;
+
+int main(int,char *[])
+{
+
+ const bu::quantity<bu::si::length> T1(2.0 * bu::si::seconds);
+
+ return 0;
+}
diff --git a/src/boost/libs/units/test/fail_quantity_non_unit.cpp b/src/boost/libs/units/test/fail_quantity_non_unit.cpp
new file mode 100644
index 000000000..646160d61
--- /dev/null
+++ b/src/boost/libs/units/test/fail_quantity_non_unit.cpp
@@ -0,0 +1,37 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2008 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)
+
+/**
+\file
+
+\brief fail_quantity_non_unit.cpp
+
+\details
+
+Make sure that trying to use a base_unit as though
+it were a unit fails.
+
+Output:
+@verbatim
+@endverbatim
+**/
+
+#include <boost/units/quantity.hpp>
+#include <boost/units/base_units/si/meter.hpp>
+
+namespace bu = boost::units;
+
+int main(int,char *[])
+{
+
+ bu::quantity<bu::si::meter_base_unit> q;
+
+
+ return 0;
+}
diff --git a/src/boost/libs/units/test/fail_quantity_scalar_add.cpp b/src/boost/libs/units/test/fail_quantity_scalar_add.cpp
new file mode 100644
index 000000000..94cc8f273
--- /dev/null
+++ b/src/boost/libs/units/test/fail_quantity_scalar_add.cpp
@@ -0,0 +1,35 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2008 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)
+
+/**
+\file
+
+\brief fail_quantity_scalar_add.cpp
+
+\details
+Test addition of quantity and scalar.
+
+Output:
+@verbatim
+@endverbatim
+**/
+
+#include <boost/units/quantity.hpp>
+#include <boost/units/systems/si.hpp>
+
+namespace bu = boost::units;
+
+int main(int argc,char *argv[])
+{
+
+ 2.0 * bu::si::meters + 2.0;
+
+ return 0;
+}
diff --git a/src/boost/libs/units/test/fail_quantity_scalar_sub.cpp b/src/boost/libs/units/test/fail_quantity_scalar_sub.cpp
new file mode 100644
index 000000000..a4b93f13a
--- /dev/null
+++ b/src/boost/libs/units/test/fail_quantity_scalar_sub.cpp
@@ -0,0 +1,35 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2008 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)
+
+/**
+\file
+
+\brief fail_quantity_scalar_sub.cpp
+
+\details
+Test subtraction of quantity and scalar.
+
+Output:
+@verbatim
+@endverbatim
+**/
+
+#include <boost/units/quantity.hpp>
+#include <boost/units/systems/si.hpp>
+
+namespace bu = boost::units;
+
+int main(int argc,char *argv[])
+{
+
+ 2.0 * bu::si::meters - 2.0;
+
+ return 0;
+}
diff --git a/src/boost/libs/units/test/fail_quantity_sub_assign.cpp b/src/boost/libs/units/test/fail_quantity_sub_assign.cpp
new file mode 100644
index 000000000..65ea62fed
--- /dev/null
+++ b/src/boost/libs/units/test/fail_quantity_sub_assign.cpp
@@ -0,0 +1,36 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2008 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)
+
+/**
+\file
+
+\brief fail_quantity_sub_assign.cpp
+
+\details
+Test -= of quantity from different dimensions.
+
+Output:
+@verbatim
+@endverbatim
+**/
+
+#include <boost/units/quantity.hpp>
+#include <boost/units/systems/si.hpp>
+
+namespace bu = boost::units;
+
+int main(int,char *[])
+{
+
+ bu::quantity<bu::si::length> T1;
+ T1 -= 2.0 * bu::si::seconds;
+
+ return 0;
+}
diff --git a/src/boost/libs/units/test/fail_quantity_subtract.cpp b/src/boost/libs/units/test/fail_quantity_subtract.cpp
new file mode 100644
index 000000000..65f71e9b3
--- /dev/null
+++ b/src/boost/libs/units/test/fail_quantity_subtract.cpp
@@ -0,0 +1,35 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2008 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)
+
+/**
+\file
+
+\brief fail_quantity_subtract.cpp
+
+\details
+Test subtraction of quantities with different dimensions.
+
+Output:
+@verbatim
+@endverbatim
+**/
+
+#include <boost/units/quantity.hpp>
+#include <boost/units/systems/si.hpp>
+
+namespace bu = boost::units;
+
+int main(int argc,char *argv[])
+{
+
+ 2.0 * bu::si::seconds - 2.0 * bu::si::meters;
+
+ return 0;
+}
diff --git a/src/boost/libs/units/test/fail_quantity_unit_add.cpp b/src/boost/libs/units/test/fail_quantity_unit_add.cpp
new file mode 100644
index 000000000..537656bcf
--- /dev/null
+++ b/src/boost/libs/units/test/fail_quantity_unit_add.cpp
@@ -0,0 +1,35 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2008 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)
+
+/**
+\file
+
+\brief fail_quantity_unit_add.cpp
+
+\details
+Test addition of quantity and unit.
+
+Output:
+@verbatim
+@endverbatim
+**/
+
+#include <boost/units/quantity.hpp>
+#include <boost/units/systems/si.hpp>
+
+namespace bu = boost::units;
+
+int main(int argc,char *argv[])
+{
+
+ 2.0 * bu::si::meters + bu::si::meters;
+
+ return 0;
+}
diff --git a/src/boost/libs/units/test/fail_quantity_unit_subtract.cpp b/src/boost/libs/units/test/fail_quantity_unit_subtract.cpp
new file mode 100644
index 000000000..bcd9260c5
--- /dev/null
+++ b/src/boost/libs/units/test/fail_quantity_unit_subtract.cpp
@@ -0,0 +1,35 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2008 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)
+
+/**
+\file
+
+\brief fail_quantity_unit_subtract.cpp
+
+\details
+Test subtraction of quantity and unit.
+
+Output:
+@verbatim
+@endverbatim
+**/
+
+#include <boost/units/quantity.hpp>
+#include <boost/units/systems/si.hpp>
+
+namespace bu = boost::units;
+
+int main(int argc,char *argv[])
+{
+
+ 2.0 * bu::si::meters - bu::si::meters;
+
+ return 0;
+}
diff --git a/src/boost/libs/units/test/fail_scalar_quantity_add.cpp b/src/boost/libs/units/test/fail_scalar_quantity_add.cpp
new file mode 100644
index 000000000..072252489
--- /dev/null
+++ b/src/boost/libs/units/test/fail_scalar_quantity_add.cpp
@@ -0,0 +1,35 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2008 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)
+
+/**
+\file
+
+\brief fail_scalar_quantity_add.cpp
+
+\details
+Test addition of scalar and quantity.
+
+Output:
+@verbatim
+@endverbatim
+**/
+
+#include <boost/units/quantity.hpp>
+#include <boost/units/systems/si.hpp>
+
+namespace bu = boost::units;
+
+int main(int argc,char *argv[])
+{
+
+ 2.0 + 2.0 * bu::si::meters;
+
+ return 0;
+}
diff --git a/src/boost/libs/units/test/fail_scalar_quantity_sub.cpp b/src/boost/libs/units/test/fail_scalar_quantity_sub.cpp
new file mode 100644
index 000000000..44e6a7d1a
--- /dev/null
+++ b/src/boost/libs/units/test/fail_scalar_quantity_sub.cpp
@@ -0,0 +1,35 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2008 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)
+
+/**
+\file
+
+\brief fail_scalar_quantity_sub.cpp
+
+\details
+Test subtraction of scalar and quantity.
+
+Output:
+@verbatim
+@endverbatim
+**/
+
+#include <boost/units/quantity.hpp>
+#include <boost/units/systems/si.hpp>
+
+namespace bu = boost::units;
+
+int main(int argc,char *argv[])
+{
+
+ 2.0 - 2.0 * bu::si::meters;
+
+ return 0;
+}
diff --git a/src/boost/libs/units/test/fail_unit_quantity_add.cpp b/src/boost/libs/units/test/fail_unit_quantity_add.cpp
new file mode 100644
index 000000000..512d3329c
--- /dev/null
+++ b/src/boost/libs/units/test/fail_unit_quantity_add.cpp
@@ -0,0 +1,35 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2008 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)
+
+/**
+\file
+
+\brief fail_unit_quantity_add.cpp
+
+\details
+Test addition of unit and quantity.
+
+Output:
+@verbatim
+@endverbatim
+**/
+
+#include <boost/units/quantity.hpp>
+#include <boost/units/systems/si.hpp>
+
+namespace bu = boost::units;
+
+int main(int argc,char *argv[])
+{
+
+ bu::si::meters + 2.0 * bu::si::meters;
+
+ return 0;
+}
diff --git a/src/boost/libs/units/test/fail_unit_quantity_subtract.cpp b/src/boost/libs/units/test/fail_unit_quantity_subtract.cpp
new file mode 100644
index 000000000..512d3329c
--- /dev/null
+++ b/src/boost/libs/units/test/fail_unit_quantity_subtract.cpp
@@ -0,0 +1,35 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2008 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)
+
+/**
+\file
+
+\brief fail_unit_quantity_add.cpp
+
+\details
+Test addition of unit and quantity.
+
+Output:
+@verbatim
+@endverbatim
+**/
+
+#include <boost/units/quantity.hpp>
+#include <boost/units/systems/si.hpp>
+
+namespace bu = boost::units;
+
+int main(int argc,char *argv[])
+{
+
+ bu::si::meters + 2.0 * bu::si::meters;
+
+ return 0;
+}
diff --git a/src/boost/libs/units/test/test_absolute.cpp b/src/boost/libs/units/test/test_absolute.cpp
new file mode 100644
index 000000000..2908612f5
--- /dev/null
+++ b/src/boost/libs/units/test/test_absolute.cpp
@@ -0,0 +1,68 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2008 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)
+
+/**
+\file
+
+\brief test_absolute.cpp
+
+\details
+Test absolute units.
+
+Output:
+@verbatim
+@endverbatim
+**/
+
+#include <boost/units/quantity.hpp>
+#include <boost/units/absolute.hpp>
+#include <boost/units/unit.hpp>
+#include <boost/units/make_system.hpp>
+#include <boost/units/physical_dimensions.hpp>
+#include <boost/units/base_units/si/kelvin.hpp>
+#include <boost/units/base_units/temperature/celsius.hpp>
+#include <boost/units/base_units/temperature/fahrenheit.hpp>
+
+#include <iostream>
+
+#include <boost/test/minimal.hpp>
+
+#define BOOST_UNITS_CHECK_CLOSE(a, b) (BOOST_CHECK((std::abs((a) - (b)) < .0000001)))
+
+namespace bu = boost::units;
+using bu::si::kelvin_base_unit;
+using bu::temperature::celsius_base_unit;
+using bu::temperature::fahrenheit_base_unit;
+
+typedef bu::unit<bu::temperature_dimension,bu::make_system<kelvin_base_unit>::type> kelvin_type;
+
+typedef bu::unit<bu::temperature_dimension,bu::make_system<celsius_base_unit>::type> celsius_type;
+
+typedef bu::unit<bu::temperature_dimension,bu::make_system<fahrenheit_base_unit>::type> fahrenheit_type;
+
+int test_main(int,char *[])
+{
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<bu::absolute<fahrenheit_type> > q1(212.0 * bu::absolute<fahrenheit_type>());
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<bu::absolute<celsius_type> > q2(0.0 * bu::absolute<celsius_type>());
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<bu::absolute<fahrenheit_type> > q3(q2);
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<fahrenheit_type> q4(q1 - q3);
+
+ BOOST_UNITS_CHECK_CLOSE(q4.value(), 180.0);
+
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<bu::absolute<kelvin_type> > q5(static_cast<bu::quantity<kelvin_type> >(q4) + static_cast<bu::quantity<bu::absolute<kelvin_type> > >(q2));
+
+ BOOST_UNITS_CHECK_CLOSE(q5.value(), 373.15);
+
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<bu::absolute<fahrenheit_type> > q6(q5);
+
+ BOOST_UNITS_CHECK_CLOSE(q6.value(), 212.0);
+
+ return(0);
+}
diff --git a/src/boost/libs/units/test/test_base_dimension.cpp b/src/boost/libs/units/test/test_base_dimension.cpp
new file mode 100644
index 000000000..27cc6dcdb
--- /dev/null
+++ b/src/boost/libs/units/test/test_base_dimension.cpp
@@ -0,0 +1,31 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2008 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)
+
+/**
+\file
+
+\brief test_base_dimension.cpp
+
+\details
+Test base_dimension class.
+
+Output:
+@verbatim
+@endverbatim
+**/
+
+#include <boost/units/base_dimension.hpp>
+
+struct dimension : boost::units::base_dimension<dimension, 1> {
+ typedef boost::units::base_dimension<dimension, 1> base;
+};
+
+int main() {
+}
diff --git a/src/boost/libs/units/test/test_cmath.cpp b/src/boost/libs/units/test/test_cmath.cpp
new file mode 100644
index 000000000..85a5119c0
--- /dev/null
+++ b/src/boost/libs/units/test/test_cmath.cpp
@@ -0,0 +1,173 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2008 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)
+
+/**
+\file
+
+\brief test_units_1.cpp
+
+\details
+Test unit class.
+
+Output:
+@verbatim
+@endverbatim
+**/
+
+#include <limits>
+
+#include <boost/units/cmath.hpp>
+
+#include "test_header.hpp"
+
+namespace bu = boost::units;
+
+int test_main(int,char *[])
+{
+ BOOST_CONSTEXPR_OR_CONST double inf = std::numeric_limits<double>::infinity(),
+ nan = std::numeric_limits<double>::quiet_NaN();
+
+ // default constructor
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<bu::energy> E1(0.0*bu::joules),
+ E2(inf*bu::joules),
+ E3(nan*bu::joules);
+
+ BOOST_CHECK((bu::isfinite)(E1) == true);
+ BOOST_CHECK((bu::isfinite)(E2) == false);
+ BOOST_CHECK((bu::isfinite)(E3) == false);
+
+ BOOST_CHECK((bu::isinf)(E1) == false);
+ BOOST_CHECK((bu::isinf)(E2) == true);
+ BOOST_CHECK((bu::isinf)(E3) == false);
+
+ BOOST_CHECK((bu::isnan)(E1) == false);
+ BOOST_CHECK((bu::isnan)(E2) == false);
+ BOOST_CHECK((bu::isnan)(E3) == true);
+
+ BOOST_CHECK((bu::isnormal)(E1) == false);
+ BOOST_CHECK((bu::isnormal)(E2) == false);
+ BOOST_CHECK((bu::isnormal)(E3) == false);
+
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<bu::energy> E4(-2.5*bu::joules),
+ E5(2.5*bu::joules);
+
+ BOOST_CHECK((bu::isgreater)(E4,E5) == false);
+ BOOST_CHECK((bu::isgreater)(E5,E4) == true);
+ BOOST_CHECK((bu::isgreater)(E4,E4) == false);
+ BOOST_CHECK((bu::isgreater)(E3,E4) == false);
+ BOOST_CHECK((bu::isgreater)(E4,E3) == false);
+
+ BOOST_CHECK((bu::isgreaterequal)(E4,E5) == false);
+ BOOST_CHECK((bu::isgreaterequal)(E5,E4) == true);
+ BOOST_CHECK((bu::isgreaterequal)(E4,E4) == true);
+ BOOST_CHECK((bu::isgreaterequal)(E3,E4) == false);
+ BOOST_CHECK((bu::isgreaterequal)(E4,E3) == false);
+
+ BOOST_CHECK((bu::isless)(E4,E5) == true);
+ BOOST_CHECK((bu::isless)(E5,E4) == false);
+ BOOST_CHECK((bu::isless)(E4,E4) == false);
+ BOOST_CHECK((bu::isless)(E3,E4) == false);
+ BOOST_CHECK((bu::isless)(E4,E3) == false);
+
+ BOOST_CHECK((bu::islessequal)(E4,E5) == true);
+ BOOST_CHECK((bu::islessequal)(E5,E4) == false);
+ BOOST_CHECK((bu::islessequal)(E4,E4) == true);
+ BOOST_CHECK((bu::islessequal)(E3,E4) == false);
+ BOOST_CHECK((bu::islessequal)(E4,E3) == false);
+
+ BOOST_CHECK((bu::islessgreater)(E4,E5) == true);
+ BOOST_CHECK((bu::islessgreater)(E5,E4) == true);
+ BOOST_CHECK((bu::islessgreater)(E4,E4) == false);
+ BOOST_CHECK((bu::islessgreater)(E3,E4) == false);
+ BOOST_CHECK((bu::islessgreater)(E4,E3) == false);
+
+ BOOST_CHECK((bu::isunordered)(E4,E5) == false);
+ BOOST_CHECK((bu::isunordered)(E5,E4) == false);
+ BOOST_CHECK((bu::isunordered)(E4,E4) == false);
+ BOOST_CHECK((bu::isunordered)(E3,E4) == true);
+ BOOST_CHECK((bu::isunordered)(E4,E3) == true);
+
+ BOOST_CHECK((bu::abs)(E4) == E5);
+ BOOST_CHECK((bu::ceil)(E4) == -2.0*bu::joules);
+ BOOST_CHECK((bu::copysign)(E4,E5) == E5);
+ BOOST_CHECK((bu::fabs)(E4) == E5);
+ BOOST_CHECK((bu::floor)(E4) == -3.0*bu::joules);
+ BOOST_CHECK((bu::fdim)(E4,E5) == 0.0*bu::joules);
+ BOOST_CHECK((bu::fdim)(E5,E4) == E5-E4);
+
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<bu::length> L1(3.0*bu::meters),
+ L2(4.0*bu::meters);
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<bu::area> A1(4.0*bu::square_meters),
+ A2(L1*L2+A1);
+
+#if 0
+ BOOST_CHECK((bu::fma)(L1,L2,A1) == A2);
+#endif
+
+ BOOST_CHECK((bu::fmax)(E4,E5) == E5);
+ BOOST_CHECK((bu::fmin)(E4,E5) == E4);
+
+ // need to test fpclassify
+
+ BOOST_CHECK(bu::hypot(L1,L2) == 5.0*bu::meters);
+
+#if 0
+
+// BOOST_CHECK(bu::llrint(E4).value() == bu::detail::llrint(E4.value()));
+// BOOST_CHECK(bu::llround(E4).value() == bu::detail::llround(E4.value()));
+ BOOST_CHECK((bu::nearbyint)(E4).value() == (bu::detail::nearbyint)(E4.value()));
+ BOOST_CHECK((bu::rint)(E4).value() == (bu::detail::rint)(E4.value()));
+
+#endif
+
+ BOOST_CHECK((bu::nextafter)(E4,E5).value() == (boost::math::nextafter)(E4.value(),E5.value()));
+ BOOST_CHECK((bu::nextafter)(E5,E4).value() == (boost::math::nextafter)(E5.value(),E4.value()));
+
+ BOOST_CHECK((bu::nexttoward)(E4,E5).value() == (boost::math::nextafter)(E4.value(),E5.value()));
+ BOOST_CHECK((bu::nexttoward)(E5,E4).value() == (boost::math::nextafter)(E5.value(),E4.value()));
+
+ BOOST_CHECK((bu::round)(E4 - 0.00000000001 * bu::joules) == -3.0*bu::joules);
+ BOOST_CHECK((bu::round)(E5 + 0.00000000001 * bu::joules) == 3.0*bu::joules);
+ BOOST_CHECK((bu::signbit)(E4) != 0);
+ BOOST_CHECK((bu::signbit)(E5) == 0);
+ BOOST_CHECK((bu::trunc)(E4) == -2.0*bu::joules);
+ BOOST_CHECK((bu::trunc)(E5) == 2.0*bu::joules);
+
+ BOOST_CHECK((bu::fmod)(E4,E5) == -0.0*bu::joules);
+
+ bu::quantity<bu::energy> pint;
+
+ BOOST_CHECK((bu::modf)(E4,&pint) == -0.5*bu::joules);
+ BOOST_CHECK(pint == -2.0*bu::joules);
+
+ int ex;
+ const bu::quantity<bu::energy> E6((bu::frexp)(E4,&ex));
+
+ BOOST_CHECK(E6 == -0.625*bu::joules);
+ BOOST_CHECK(ex == 2);
+ BOOST_CHECK((bu::ldexp)(E6,ex) == E4);
+
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<bu::dimensionless> E7(1.0);
+
+ BOOST_CHECK(bu::pow(E7,E7) == 1.0*1.0);
+
+ const bu::quantity<bu::dimensionless> E8((bu::exp)(E7));
+
+ BOOST_CHECK(std::abs(E8 - std::exp(1.0)) < .000001);
+ BOOST_CHECK(bu::log(E8) == E7);
+
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<bu::dimensionless> E9(100.0);
+
+ BOOST_CHECK(bu::log10(E9) == 2.0);
+
+ BOOST_CHECK(bu::sqrt(A1) == 2.0*bu::meters);
+
+ return 0;
+}
diff --git a/src/boost/libs/units/test/test_complicated_system.cpp b/src/boost/libs/units/test/test_complicated_system.cpp
new file mode 100644
index 000000000..4ac3a82d5
--- /dev/null
+++ b/src/boost/libs/units/test/test_complicated_system.cpp
@@ -0,0 +1,96 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2007-2008 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)
+
+#include <boost/type_traits/is_same.hpp>
+#include <boost/mpl/assert.hpp>
+
+#include <boost/units/base_unit.hpp>
+#include <boost/units/derived_dimension.hpp>
+#include <boost/units/make_system.hpp>
+#include <boost/units/operators.hpp>
+#include <boost/units/reduce_unit.hpp>
+#include <boost/units/unit.hpp>
+
+#include <boost/units/physical_dimensions/current.hpp>
+#include <boost/units/physical_dimensions/electric_potential.hpp>
+#include <boost/units/physical_dimensions/energy.hpp>
+#include <boost/units/physical_dimensions/force.hpp>
+#include <boost/units/physical_dimensions/length.hpp>
+#include <boost/units/physical_dimensions/mass.hpp>
+#include <boost/units/physical_dimensions/time.hpp>
+
+namespace test_system1 {
+
+// the base units in the system will be:
+//
+// volts = m^2 kg s^-2 C^-1
+// newtons = m kg s^-2
+// joules = m^2 kg s^-2
+
+// we will find the representation of m^-1 C^-1 = V N J^-2 = m^-1 C^-1
+
+// reducing the system should generate the matrix equation
+// 2 1 2
+// 1 1 1 x = c
+// -2 -2 -2
+// -1 0 0
+
+struct volt : boost::units::base_unit<volt, boost::units::electric_potential_dimension, 1> {};
+struct newton : boost::units::base_unit<newton, boost::units::force_dimension, 2> {};
+struct joule : boost::units::base_unit<joule, boost::units::energy_dimension, 3> {};
+
+typedef boost::units::make_system<volt, newton, joule>::type complicated_system;
+
+typedef boost::units::derived_dimension<
+ boost::units::length_base_dimension, -1,
+ boost::units::time_base_dimension, -1,
+ boost::units::current_base_dimension, -1
+>::type dimension;
+
+typedef boost::units::reduce_unit<boost::units::unit<dimension, complicated_system> >::type reduced;
+
+typedef boost::units::divide_typeof_helper<
+ boost::units::multiply_typeof_helper<volt::unit_type, newton::unit_type>::type,
+ boost::units::power_typeof_helper<joule::unit_type, boost::units::static_rational<2> >::type
+>::type expected;
+
+void test() {
+ BOOST_MPL_ASSERT((boost::is_same<reduced, expected>));
+}
+
+}
+
+namespace test_system2 {
+
+// the base units in the system will be:
+//
+// kilograms = kg
+// meters = m
+
+// we will find the representation of m and kg
+
+// reducing the system should generate the matrix equation
+// 0 1
+// 1 0 x = c
+
+struct kilogram : boost::units::base_unit<kilogram, boost::units::mass_dimension, 4> {};
+struct meter : boost::units::base_unit<meter, boost::units::length_dimension, 5> {};
+
+typedef boost::units::make_system<meter, kilogram>::type mk_system;
+
+typedef boost::units::reduce_unit<boost::units::unit<boost::units::mass_dimension, mk_system> >::type mass_unit;
+typedef boost::units::reduce_unit<boost::units::unit<boost::units::length_dimension, mk_system> >::type length_unit;
+
+void test() {
+ BOOST_MPL_ASSERT((boost::is_same<mass_unit, kilogram::unit_type>));
+ BOOST_MPL_ASSERT((boost::is_same<length_unit, meter::unit_type>));
+}
+
+}
diff --git a/src/boost/libs/units/test/test_constants.cpp b/src/boost/libs/units/test/test_constants.cpp
new file mode 100644
index 000000000..55b45a1c5
--- /dev/null
+++ b/src/boost/libs/units/test/test_constants.cpp
@@ -0,0 +1,87 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2009 Matthias Christian Schabel
+// Copyright (C) 2007-2009 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)
+
+/**
+\file
+
+\brief test_constants.cpp
+
+\details
+Test all combinations of operators with the constants.
+
+**/
+
+#include <boost/units/systems/detail/constants.hpp>
+#include <boost/units/quantity.hpp>
+#include <boost/units/pow.hpp>
+#include <boost/units/systems/si/length.hpp>
+#include <boost/units/systems/si/time.hpp>
+
+using boost::units::quantity;
+using boost::units::si::length;
+using boost::units::si::meters;
+using boost::units::si::seconds;
+using boost::units::static_rational;
+using boost::units::pow;
+using boost::units::root;
+
+BOOST_UNITS_PHYSICAL_CONSTANT(length_constant, quantity<length>, 2.0 * meters, 0.5 * meters);
+
+template<class T>
+void check_same(const T&, const T&);
+
+template<class T>
+typename T::value_type unwrap(const boost::units::constant<T>&);
+
+template<class T>
+T unwrap(const T&);
+
+#define BOOST_UNITS_CHECK_RESULT(arg1, op, arg2) check_same((arg1) op (arg2), unwrap(arg1) op unwrap(arg2));
+
+void test_add() {
+ BOOST_UNITS_CHECK_RESULT(length_constant, +, length_constant);
+ BOOST_UNITS_CHECK_RESULT(length_constant, +, 1.0 * meters);
+ BOOST_UNITS_CHECK_RESULT(1.0* meters, +, length_constant);
+}
+
+void test_subtract() {
+ BOOST_UNITS_CHECK_RESULT(length_constant, -, length_constant);
+ BOOST_UNITS_CHECK_RESULT(length_constant, -, 1.0 * meters);
+ BOOST_UNITS_CHECK_RESULT(1.0* meters, -, length_constant);
+}
+
+void test_multiply() {
+ BOOST_UNITS_CHECK_RESULT(length_constant, *, length_constant);
+ BOOST_UNITS_CHECK_RESULT(length_constant, *, 1.0 * seconds);
+ BOOST_UNITS_CHECK_RESULT(1.0 * seconds, *, length_constant);
+ BOOST_UNITS_CHECK_RESULT(length_constant, *, 1.0);
+ BOOST_UNITS_CHECK_RESULT(1.0, *, length_constant);
+ BOOST_UNITS_CHECK_RESULT(length_constant, *, seconds);
+ BOOST_UNITS_CHECK_RESULT(seconds, *, length_constant);
+}
+
+void test_divide() {
+ BOOST_UNITS_CHECK_RESULT(length_constant, /, length_constant);
+ BOOST_UNITS_CHECK_RESULT(length_constant, /, 1.0 * seconds);
+ BOOST_UNITS_CHECK_RESULT(1.0 * seconds, /, length_constant);
+ BOOST_UNITS_CHECK_RESULT(length_constant, /, 1.0);
+ BOOST_UNITS_CHECK_RESULT(1.0, /, length_constant);
+ BOOST_UNITS_CHECK_RESULT(length_constant, /, seconds);
+ BOOST_UNITS_CHECK_RESULT(seconds, /, length_constant);
+}
+
+void test_pow() {
+ check_same(pow<2>(length_constant), pow<2>(unwrap(length_constant)));
+ check_same(root<2>(length_constant), root<2>(unwrap(length_constant)));
+ check_same(pow<5>(length_constant), pow<5>(unwrap(length_constant)));
+ check_same(root<5>(length_constant), root<5>(unwrap(length_constant)));
+ check_same(pow<static_rational<2, 3> >(length_constant), pow<static_rational<2, 3> >(unwrap(length_constant)));
+ check_same(root<static_rational<2, 3> >(length_constant), root<static_rational<2, 3> >(unwrap(length_constant)));
+}
diff --git a/src/boost/libs/units/test/test_conversion.cpp b/src/boost/libs/units/test/test_conversion.cpp
new file mode 100644
index 000000000..170152451
--- /dev/null
+++ b/src/boost/libs/units/test/test_conversion.cpp
@@ -0,0 +1,110 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2008 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)
+
+/**
+\file
+
+\brief test_conversion.cpp
+
+\details
+Test conversion between quantities.
+
+Output:
+@verbatim
+@endverbatim
+**/
+
+#include <boost/units/quantity.hpp>
+#include <boost/units/systems/si.hpp>
+#include <boost/units/systems/cgs.hpp>
+
+#include <iostream>
+
+#define BOOST_TEST_MAIN
+
+#include <boost/test/unit_test.hpp>
+
+#define BOOST_UNITS_CHECK_CLOSE(a, b) BOOST_CHECK_CLOSE_FRACTION(a, b, .0000001)
+
+namespace bu = boost::units;
+
+typedef bu::si::length si_length;
+typedef bu::si::time si_time;
+typedef bu::si::mass si_mass;
+typedef bu::si::area si_area;
+
+typedef bu::cgs::length cgs_length;
+typedef bu::cgs::time cgs_time;
+typedef bu::cgs::mass cgs_mass;
+typedef bu::cgs::area cgs_area;
+
+typedef bu::multiply_typeof_helper<si_length, cgs_length>::type mixed_length;
+typedef bu::multiply_typeof_helper<si_time, cgs_time>::type mixed_time;
+
+typedef bu::divide_typeof_helper<bu::multiply_typeof_helper<si_mass,cgs_area>::type, mixed_time>::type mixed_energy_1;
+typedef bu::divide_typeof_helper<bu::multiply_typeof_helper<cgs_mass,mixed_length>::type,
+ bu::multiply_typeof_helper<cgs_time,cgs_time>::type >::type mixed_energy_2;
+
+BOOST_AUTO_TEST_CASE(test_conversion) {
+ BOOST_CHECK_EQUAL(1, 1);
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<mixed_length> a1(2.0 * mixed_length());
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<si_area> a2(a1);
+
+ BOOST_UNITS_CHECK_CLOSE(a2.value(), .02);
+
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<mixed_length> a3(a2);
+
+ BOOST_UNITS_CHECK_CLOSE(a3.value(), 2.0);
+
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<mixed_energy_1> e1(2.0 * mixed_energy_1());
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<mixed_energy_2> e2(e1);
+
+ BOOST_UNITS_CHECK_CLOSE(e2.value(), 20.0);
+
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<bu::si::energy> e3(e1);
+ BOOST_UNITS_CHECK_CLOSE(e3.value(), .0002);
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<mixed_energy_2> e4(e3);
+ BOOST_UNITS_CHECK_CLOSE(e4.value(), 20.0);
+
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<bu::cgs::force> F0 = 20 * bu::cgs::dyne;
+ BOOST_UNITS_CHECK_CLOSE(F0.value(), 20.0);
+
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<bu::si::force> F3(F0);
+ BOOST_UNITS_CHECK_CLOSE(F3.value(), 2.0e-4);
+
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<bu::si::force> F5(20 * bu::cgs::dyne);
+ BOOST_UNITS_CHECK_CLOSE(F5.value(), 2.0e-4);
+
+ // same type
+ BOOST_CHECK_EQUAL(boost::units::conversion_factor(si_length(), si_length()), 1.0);
+}
+
+BOOST_AUTO_TEST_CASE(test_dimensionless_conversions) {
+ typedef bu::divide_typeof_helper<bu::cgs::force, bu::si::force>::type mixed_dimensionless;
+
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<bu::si::dimensionless> dimensionless_test1(1.0*bu::cgs::dyne/bu::si::newton);
+ BOOST_CHECK(dimensionless_test1 == 1e-5);
+
+ typedef bu::multiply_typeof_helper<bu::si::length, bu::cgs::length>::type m_cm;
+ typedef bu::divide_typeof_helper<m_cm, m_cm>::type heterogeneous_dimensionless;
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<heterogeneous_dimensionless> dimensionless_test2(1.0*bu::cgs::dyne/bu::si::newton);
+ BOOST_CHECK(dimensionless_test2.value() == 1e-5);
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<bu::divide_typeof_helper<bu::cgs::force, bu::si::force>::type> dimensionless_test3(dimensionless_test2);
+ BOOST_UNITS_CHECK_CLOSE(dimensionless_test3.value(), 1.0);
+
+ BOOST_UNITS_CHECK_CLOSE(boost::units::conversion_factor(mixed_dimensionless(), heterogeneous_dimensionless()), 1e-5);
+ BOOST_UNITS_CHECK_CLOSE(boost::units::conversion_factor(heterogeneous_dimensionless(), mixed_dimensionless()), 1e5);
+
+
+ //m/cm -> g/kg
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<bu::divide_typeof_helper<bu::si::length, bu::cgs::length>::type> dimensionless_test4(2.0 * bu::si::meters / bu::cgs::centimeters);
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<bu::divide_typeof_helper<bu::cgs::mass, bu::si::mass>::type> dimensionless_test5(dimensionless_test4);
+ BOOST_UNITS_CHECK_CLOSE(dimensionless_test5.value(), 2e5);
+}
diff --git a/src/boost/libs/units/test/test_custom_unit.cpp b/src/boost/libs/units/test/test_custom_unit.cpp
new file mode 100644
index 000000000..42e7d6e8b
--- /dev/null
+++ b/src/boost/libs/units/test/test_custom_unit.cpp
@@ -0,0 +1,84 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2008 Matthias Christian Schabel
+// Copyright (C) 2008 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)
+
+/**
+\file
+
+\brief test_custom_unit.cpp
+
+\details
+Make sure that a minimal + - * / unit class is fully functional.
+
+Output:
+@verbatim
+@endverbatim
+**/
+
+#include <boost/units/quantity.hpp>
+
+#include <boost/test/minimal.hpp>
+
+namespace bu = boost::units;
+
+template<int Mass, int Length, int Time>
+struct simple_unit {};
+
+BOOST_TYPEOF_REGISTER_TEMPLATE(simple_unit, (int)(int)(int))
+
+template<int Mass, int Length, int Time>
+simple_unit<Mass, Length, Time> operator+(const simple_unit<Mass, Length, Time>&,
+ const simple_unit<Mass, Length, Time>&)
+{
+ return simple_unit<Mass, Length, Time>();
+}
+
+template<int Mass, int Length, int Time>
+simple_unit<Mass, Length, Time> operator-(const simple_unit<Mass, Length, Time>&,
+ const simple_unit<Mass, Length, Time>&)
+{
+ return simple_unit<Mass, Length, Time>();
+}
+
+template<int Mass1, int Length1, int Time1, int Mass2, int Length2, int Time2>
+simple_unit<Mass1 + Mass2, Length1 + Length2, Time1 + Time2>
+operator*(const simple_unit<Mass1, Length1, Time1>&,
+ const simple_unit<Mass2, Length2, Time2>&)
+{
+ return simple_unit<Mass1 + Mass2, Length1 + Length2, Time1 + Time2>();
+}
+
+template<int Mass1, int Length1, int Time1, int Mass2, int Length2, int Time2>
+simple_unit<Mass1 - Mass2, Length1 - Length2, Time1 - Time2>
+operator/(const simple_unit<Mass1, Length1, Time1>&,
+ const simple_unit<Mass2, Length2, Time2>&)
+{
+ return simple_unit<Mass1 - Mass2, Length1 - Length2, Time1 - Time2>();
+}
+
+int test_main(int,char *[])
+{
+ bu::quantity<simple_unit<1, 0, 0> > mass = bu::quantity<simple_unit<1, 0, 0> >::from_value(2);
+ bu::quantity<simple_unit<0, 1, 0> > length = bu::quantity<simple_unit<0, 1, 0> >::from_value(4);
+
+ bu::quantity<simple_unit<1, 1, 0> > ml = mass * length;
+ bu::quantity<simple_unit<1, -1, 0> > m_per_l = mass/length;
+
+ BOOST_CHECK(ml.value() == 8);
+ BOOST_CHECK(m_per_l.value() == 0.5);
+
+ mass += mass;
+
+ BOOST_CHECK(mass.value() == 4);
+
+ length -= length;
+ BOOST_CHECK(length.value() == 0);
+
+ return 0;
+}
diff --git a/src/boost/libs/units/test/test_default_conversion.cpp b/src/boost/libs/units/test/test_default_conversion.cpp
new file mode 100644
index 000000000..f05aac699
--- /dev/null
+++ b/src/boost/libs/units/test/test_default_conversion.cpp
@@ -0,0 +1,78 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2008 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)
+
+#include <boost/test/minimal.hpp>
+
+#include <boost/units/base_dimension.hpp>
+#include <boost/units/base_unit.hpp>
+#include <boost/units/make_system.hpp>
+#include <boost/units/scaled_base_unit.hpp>
+#include <boost/units/conversion.hpp>
+#include <boost/units/unit.hpp>
+
+struct dimension1_tag : boost::units::base_dimension<dimension1_tag, 1> {};
+struct dimension2_tag : boost::units::base_dimension<dimension2_tag, 2> {};
+
+typedef dimension1_tag::dimension_type dimension1;
+typedef dimension2_tag::dimension_type dimension2;
+typedef boost::mpl::times<dimension1, dimension2>::type dimension12;
+
+struct unit1_tag : boost::units::base_unit<unit1_tag, dimension1, 1> {};
+struct unit2_tag : boost::units::base_unit<unit2_tag, dimension1, 2> {};
+struct unit3_tag : boost::units::base_unit<unit3_tag, dimension1, 3> {};
+struct unit4_tag : boost::units::base_unit<unit4_tag, dimension2, 4> {};
+struct unit5_tag : boost::units::base_unit<unit5_tag, dimension12, 5> {};
+struct unit6_tag : boost::units::base_unit<unit6_tag, dimension1, 6> {};
+struct unit7_tag : boost::units::base_unit<unit7_tag, dimension1, 7> {};
+
+BOOST_UNITS_DEFINE_CONVERSION_FACTOR(unit1_tag, unit2_tag, double, 2.0);
+BOOST_UNITS_DEFINE_CONVERSION_FACTOR(unit2_tag, unit3_tag, double, 3.0);
+BOOST_UNITS_DEFINE_CONVERSION_FACTOR(unit6_tag, unit3_tag, double, 5.0);
+BOOST_UNITS_DEFINE_CONVERSION_FACTOR(unit7_tag, unit1_tag, double, 7.0);
+
+typedef boost::units::multiply_typeof_helper<unit3_tag::unit_type, unit4_tag::unit_type>::type unit34_type;
+BOOST_UNITS_DEFINE_CONVERSION_FACTOR(unit5_tag, unit34_type , double, 5.0);
+
+template<class BaseUnit>
+struct make_unit {
+ typedef boost::units::unit<
+ typename BaseUnit::dimension_type,
+ typename boost::units::make_system<BaseUnit>::type> type;
+};
+
+BOOST_UNITS_DEFAULT_CONVERSION(unit1_tag, unit2_tag);
+BOOST_UNITS_DEFAULT_CONVERSION(unit3_tag, unit2_tag);
+BOOST_UNITS_DEFAULT_CONVERSION(unit5_tag, unit34_type);
+BOOST_UNITS_DEFAULT_CONVERSION(unit6_tag, make_unit<unit3_tag>::type);
+BOOST_UNITS_DEFAULT_CONVERSION(unit7_tag, make_unit<unit1_tag>::type);
+
+int test_main(int, char*[]) {
+ BOOST_CONSTEXPR_OR_CONST double value1 = boost::units::conversion_factor(unit3_tag::unit_type(), unit1_tag::unit_type());
+ BOOST_CHECK(std::abs(value1 - 1.0/6.0) < .0000000001);
+ BOOST_CONSTEXPR_OR_CONST double value2 = boost::units::conversion_factor(unit5_tag::unit_type() / unit4_tag::unit_type(), unit1_tag::unit_type());
+ BOOST_CHECK(std::abs(value2 - 5.0/6.0) < .0000000001);
+ typedef boost::units::scaled_base_unit<unit5_tag, boost::units::scale<2, boost::units::static_rational<1> > > scaled_unit5_tag;
+ BOOST_CONSTEXPR_OR_CONST double value3 = boost::units::conversion_factor(scaled_unit5_tag::unit_type() / unit4_tag::unit_type(), unit1_tag::unit_type());
+ BOOST_CHECK(std::abs(value3 - 10.0/6.0) < .0000000001);
+
+ // check homogeneous unit conversions
+ BOOST_CONSTEXPR_OR_CONST double value4 = boost::units::conversion_factor(make_unit<unit3_tag>::type(), make_unit<unit1_tag>::type());
+ BOOST_CHECK(std::abs(value4 - 1.0/6.0) < .0000000001);
+ BOOST_CONSTEXPR_OR_CONST double value5 = boost::units::conversion_factor(unit3_tag::unit_type(), make_unit<unit1_tag>::type());
+ BOOST_CHECK(std::abs(value5 - 1.0/6.0) < .0000000001);
+ BOOST_CONSTEXPR_OR_CONST double value6 = boost::units::conversion_factor(make_unit<unit3_tag>::type(), unit1_tag::unit_type());
+ BOOST_CHECK(std::abs(value6 - 1.0/6.0) < .0000000001);
+
+ // check chained homogeneous conversions
+ BOOST_CONSTEXPR_OR_CONST double value7 = boost::units::conversion_factor(unit6_tag::unit_type(), unit7_tag::unit_type());
+ BOOST_CHECK(std::abs(value7 - 5.0/42.0) < .0000000001);
+
+ return(0);
+}
diff --git a/src/boost/libs/units/test/test_dimensionless_ice1.cpp b/src/boost/libs/units/test/test_dimensionless_ice1.cpp
new file mode 100644
index 000000000..06ab61eec
--- /dev/null
+++ b/src/boost/libs/units/test/test_dimensionless_ice1.cpp
@@ -0,0 +1,26 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2008 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)
+
+#include <boost/core/ignore_unused.hpp>
+#include <boost/units/systems/si/base.hpp>
+#include <boost/units/quantity.hpp>
+
+void foo()
+{
+ BOOST_CONSTEXPR_OR_CONST boost::units::quantity<boost::units::si::dimensionless> d = boost::units::quantity< boost::units::si::dimensionless >();
+ boost::ignore_unused(d);
+}
+
+#include <boost/test/test_tools.hpp>
+
+int main()
+{
+ BOOST_CHECK( 1 == 2 );
+}
diff --git a/src/boost/libs/units/test/test_dimensionless_ice2.cpp b/src/boost/libs/units/test/test_dimensionless_ice2.cpp
new file mode 100644
index 000000000..b04e6544f
--- /dev/null
+++ b/src/boost/libs/units/test/test_dimensionless_ice2.cpp
@@ -0,0 +1,25 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2008 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)
+
+#include <boost/units/systems/si/length.hpp>
+#include <boost/units/systems/cgs/length.hpp>
+#include <boost/units/quantity.hpp>
+
+void foo()
+{
+ BOOST_CONSTEXPR_OR_CONST boost::units::quantity<boost::units::si::dimensionless> d(1.0 * boost::units::si::meters / boost::units::cgs::centimeters);
+}
+
+#include <boost/test/test_tools.hpp>
+
+int main()
+{
+ BOOST_CHECK( 1 == 2 );
+}
diff --git a/src/boost/libs/units/test/test_dimensionless_quantity.cpp b/src/boost/libs/units/test/test_dimensionless_quantity.cpp
new file mode 100644
index 000000000..197d7c9d2
--- /dev/null
+++ b/src/boost/libs/units/test/test_dimensionless_quantity.cpp
@@ -0,0 +1,216 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2008 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)
+
+/**
+\file
+
+\brief test_dimensionless_quantity.cpp
+
+\details
+Test unit class.
+
+Output:
+@verbatim
+@endverbatim
+**/
+
+#include "test_header.hpp"
+
+#include <boost/units/pow.hpp>
+
+namespace bu = boost::units;
+
+BOOST_STATIC_CONSTEXPR double E_ = 2.718281828459045235360287471352662497757;
+
+int test_main(int,char *[])
+{
+ // default constructor
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<bu::dimensionless> E1;
+ BOOST_CHECK(E1.value() == double());
+
+ // value_type constructor
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<bu::dimensionless> E2(E_);
+ BOOST_CHECK(E2.value() == E_);
+
+ // copy constructor
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<bu::dimensionless> E3(E2);
+ BOOST_CHECK(E3.value() == E_);
+
+ // operator=
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<bu::dimensionless> E4 = E2;
+ BOOST_CHECK(E4.value() == E_);
+
+ // implicit copy constructor value_type conversion
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<bu::dimensionless,float> E5(E2);
+ BOOST_UNITS_CHECK_CLOSE(E5.value(), float(E_));
+
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<bu::dimensionless,long> E6(E2);
+ BOOST_CHECK(E6.value() == long(E_));
+
+ // implicit operator= value_type conversion
+ // narrowing conversion disallowed
+// BOOST_CONSTEXPR_OR_CONST bu::quantity<bu::dimensionless,float> E7 = E2;
+// BOOST_UNITS_CHECK_CLOSE(E7.value(),float(E_));
+
+ // narrowing conversion disallowed
+// BOOST_CONSTEXPR_OR_CONST bu::quantity<bu::dimensionless,long> E8 = E2;
+// BOOST_CHECK(E8.value() == long(E_));
+
+ // const construction
+ bu::quantity<bu::dimensionless> E9(E2);
+ BOOST_CHECK(E9.value() == E_);
+
+// // value assignment
+// E9.value() = 1.5*bu::dimensionless();
+// BOOST_CHECK(E9.value() == 1.5);
+//
+// // value assignment with implicit conversion
+// E9.value() = 1.5;
+// BOOST_CHECK(E9.value() == 1.5);
+//
+// // value assignment with implicit value_type conversion
+// E9.value() = 2*bu::dimensionless();
+// BOOST_CHECK(E9.value() == double(2));
+//
+// // value assignment with implicit value_type conversion
+// E9.value() = 2;
+// BOOST_CHECK(E9.value() == double(2));
+
+ // operator+=(this_type)
+ E9 = 2.0;
+ E9 += E9;
+ BOOST_CHECK(E9.value() == 4.0);
+
+ // operator-=(this_type)
+ E9 = 2.0;
+ E9 -= E9;
+ BOOST_CHECK(E9.value() == 0.0);
+
+ // operator*=(value_type)
+ E9 = 2.0;
+ E9 *= 2.0;
+ BOOST_CHECK(E9.value() == 4.0);
+
+ // operator/=(value_type)
+ E9 = 2.0;
+ E9 /= 2.0;
+ BOOST_CHECK(E9.value() == 1.0);
+
+ // static construct quantity from value_type
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<bu::dimensionless> E(bu::quantity<bu::dimensionless>::from_value(2.5));
+ BOOST_CHECK(E.value() == 2.5);
+
+ // implicit conversion to value_type
+ const double V1(E9);
+ BOOST_CHECK(V1 == E9.value());
+
+ const double V2 = E9;
+ BOOST_CHECK(V2 == E9.value());
+
+ // unit * scalar
+ BOOST_CHECK(bu::dimensionless()*2.0 == bu::quantity<bu::dimensionless>::from_value(2.0));
+
+ // unit / scalar
+ BOOST_CHECK(bu::dimensionless()/2.0 == bu::quantity<bu::dimensionless>::from_value(0.5));
+
+ // scalar * unit
+ BOOST_CHECK(2.0*bu::dimensionless() == bu::quantity<bu::dimensionless>::from_value(2.0));
+
+ // scalar / unit
+ BOOST_CHECK(2.0/bu::dimensionless() == bu::quantity<bu::dimensionless>::from_value(2.0));
+
+ // quantity * scalar
+ BOOST_CHECK(E*2.0 == bu::quantity<bu::dimensionless>::from_value(5.0));
+
+ // quantity / scalar
+ BOOST_CHECK(E/2.0 == bu::quantity<bu::dimensionless>::from_value(1.25));
+
+ // scalar * quantity
+ BOOST_CHECK(2.0*E == bu::quantity<bu::dimensionless>::from_value(5.0));
+
+ // scalar / quantity
+ BOOST_CHECK(2.0/E == bu::quantity<bu::dimensionless>::from_value(0.8));
+
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<bu::dimensionless> D1(1.0),
+ D2(2.0);
+
+ // unit * quantity
+ BOOST_CHECK(bu::dimensionless()*D1 == D1);
+
+ // unit / quantity
+ BOOST_CHECK(bu::dimensionless()/D1 == D1);
+
+ // quantity * unit
+ BOOST_CHECK(D1*bu::dimensionless() == D1);
+
+ // quantity / unit
+ BOOST_CHECK(D1*bu::dimensionless() == D1);
+
+ // +quantity
+ BOOST_CHECK(+D1 == 1.0*bu::dimensionless());
+
+ // -quantity
+ BOOST_CHECK(-D1 == -1.0*bu::dimensionless());
+
+ // quantity + quantity
+ BOOST_CHECK(D2+D1 == 3.0*bu::dimensionless());
+
+ // quantity - quantity
+ BOOST_CHECK(D2-D1 == 1.0*bu::dimensionless());
+
+ // quantity * quantity
+ BOOST_CHECK(D1*D2 == 2.0*bu::dimensionless());
+
+ // quantity / quantity
+ BOOST_CHECK(D2/D1 == 2.0*bu::dimensionless());
+
+ // integer power of quantity
+ BOOST_CHECK(2.0*bu::pow<2>(D2) == 2.0*std::pow(2.0,2.0)*bu::dimensionless());
+
+ // rational power of quantity
+ BOOST_CHECK((2.0*bu::pow< bu::static_rational<2,3> >(D2) == 2.0*std::pow(2.0,2.0/3.0)*bu::dimensionless()));
+
+ // integer root of quantity
+ BOOST_CHECK(2.0*bu::root<2>(D2) == 2.0*std::pow(2.0,1.0/2.0)*bu::dimensionless());
+
+ // rational root of quantity
+ BOOST_CHECK((2.0*bu::root< bu::static_rational<3,2> >(D2) == 2.0*std::pow(2.0,2.0/3.0)*bu::dimensionless()));
+
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<bu::dimensionless> A1(0.0),
+ A2(0.0),
+ A3(1.0),
+ A4(-1.0);
+
+ // operator==
+ BOOST_CHECK((A1 == A2) == true);
+ BOOST_CHECK((A1 == A3) == false);
+
+ // operator!=
+ BOOST_CHECK((A1 != A2) == false);
+ BOOST_CHECK((A1 != A3) == true);
+
+ // operator<
+ BOOST_CHECK((A1 < A2) == false);
+ BOOST_CHECK((A1 < A3) == true);
+
+ // operator<=
+ BOOST_CHECK((A1 <= A2) == true);
+ BOOST_CHECK((A1 <= A3) == true);
+
+ // operator>
+ BOOST_CHECK((A1 > A2) == false);
+ BOOST_CHECK((A1 > A4) == true);
+
+ // operator>=
+ BOOST_CHECK((A1 >= A2) == true);
+ BOOST_CHECK((A1 >= A4) == true);
+
+ return 0;
+}
diff --git a/src/boost/libs/units/test/test_header.hpp b/src/boost/libs/units/test/test_header.hpp
new file mode 100644
index 000000000..bc2ec439f
--- /dev/null
+++ b/src/boost/libs/units/test/test_header.hpp
@@ -0,0 +1,126 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2008 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)
+
+/**
+\file
+
+\brief test_header.hpp
+
+\details
+Unit system for test purposes.
+
+Output:
+@verbatim
+@endverbatim
+**/
+
+#ifndef BOOST_UNITS_TEST_HEADER_HPP
+#define BOOST_UNITS_TEST_HEADER_HPP
+
+#include <boost/test/minimal.hpp>
+
+#include <boost/units/base_dimension.hpp>
+#include <boost/units/derived_dimension.hpp>
+#include <boost/units/static_constant.hpp>
+#include <boost/units/quantity.hpp>
+#include <boost/units/io.hpp>
+#include <boost/units/base_unit.hpp>
+#include <boost/units/make_system.hpp>
+
+#include <boost/units/physical_dimensions/length.hpp>
+#include <boost/units/physical_dimensions/mass.hpp>
+#include <boost/units/physical_dimensions/time.hpp>
+
+#define BOOST_UNITS_CHECK_CLOSE(a, b) (BOOST_CHECK((std::abs((a) - (b)) < .0000001)))
+
+namespace boost {
+
+namespace units {
+
+//struct length_base_dimension : boost::units::base_dimension<length_base_dimension,1> { }; ///> base dimension of length
+//struct mass_base_dimension : boost::units::base_dimension<mass_base_dimension,2> { }; ///> base dimension of mass
+//struct time_base_dimension : boost::units::base_dimension<time_base_dimension,3> { }; ///> base dimension of time
+
+typedef length_base_dimension::dimension_type length_dimension;
+typedef mass_base_dimension::dimension_type mass_dimension;
+typedef time_base_dimension::dimension_type time_dimension;
+
+typedef derived_dimension<length_base_dimension,2>::type area_dimension;
+typedef derived_dimension<mass_base_dimension,1,
+ length_base_dimension,2,
+ time_base_dimension,-2>::type energy_dimension;
+typedef derived_dimension<mass_base_dimension,-1,
+ length_base_dimension,-2,
+ time_base_dimension,2>::type inverse_energy_dim;
+typedef derived_dimension<length_base_dimension,1,
+ time_base_dimension,-1>::type velocity_dimension;
+typedef derived_dimension<length_base_dimension,3>::type volume_dimension;
+
+/// placeholder class defining test unit system
+struct length_unit : base_unit<length_unit, length_dimension, 4> {};
+struct mass_unit : base_unit<mass_unit, mass_dimension, 5> {};
+struct time_unit : base_unit<time_unit, time_dimension, 6> {};
+
+typedef make_system<length_unit, mass_unit, time_unit>::type system;
+
+/// unit typedefs
+typedef unit<dimensionless_type,system> dimensionless;
+
+typedef unit<length_dimension,system> length;
+typedef unit<mass_dimension,system> mass;
+typedef unit<time_dimension,system> time;
+
+typedef unit<area_dimension,system> area;
+typedef unit<energy_dimension,system> energy;
+typedef unit<inverse_energy_dim,system> inverse_energy;
+typedef unit<velocity_dimension,system> velocity;
+typedef unit<volume_dimension,system> volume;
+
+/// unit constants
+BOOST_UNITS_STATIC_CONSTANT(meter,length);
+BOOST_UNITS_STATIC_CONSTANT(meters,length);
+BOOST_UNITS_STATIC_CONSTANT(kilogram,mass);
+BOOST_UNITS_STATIC_CONSTANT(kilograms,mass);
+BOOST_UNITS_STATIC_CONSTANT(second,time);
+BOOST_UNITS_STATIC_CONSTANT(seconds,time);
+
+BOOST_UNITS_STATIC_CONSTANT(square_meter,area);
+BOOST_UNITS_STATIC_CONSTANT(square_meters,area);
+BOOST_UNITS_STATIC_CONSTANT(joule,energy);
+BOOST_UNITS_STATIC_CONSTANT(joules,energy);
+BOOST_UNITS_STATIC_CONSTANT(meter_per_second,velocity);
+BOOST_UNITS_STATIC_CONSTANT(meters_per_second,velocity);
+BOOST_UNITS_STATIC_CONSTANT(cubic_meter,volume);
+BOOST_UNITS_STATIC_CONSTANT(cubic_meters,volume);
+
+template<> struct base_unit_info<length_unit>
+{
+ static std::string name() { return "meter"; }
+ static std::string symbol() { return "m"; }
+};
+//]
+
+template<> struct base_unit_info<mass_unit>
+{
+ static std::string name() { return "kilogram"; }
+ static std::string symbol() { return "kg"; }
+};
+
+template<> struct base_unit_info<time_unit>
+{
+ static std::string name() { return "second"; }
+ static std::string symbol() { return "s"; }
+};
+
+} // namespace units
+
+} // namespace boost
+
+#endif // BOOST_UNITS_TEST_HEADER_HPP
diff --git a/src/boost/libs/units/test/test_implicit_conversion.cpp b/src/boost/libs/units/test/test_implicit_conversion.cpp
new file mode 100644
index 000000000..41dfca03d
--- /dev/null
+++ b/src/boost/libs/units/test/test_implicit_conversion.cpp
@@ -0,0 +1,113 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2008 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)
+
+/**
+\file
+
+\brief test_implicit_conversion.cpp
+
+\details
+Test implicit conversions for quantity.
+
+Output:
+@verbatim
+@endverbatim
+**/
+
+#include <boost/test/minimal.hpp>
+
+#include <boost/units/static_constant.hpp>
+#include <boost/units/quantity.hpp>
+#include <boost/units/systems/si.hpp>
+#include <boost/units/systems/cgs.hpp>
+
+namespace bu = boost::units;
+
+int test_main(int,char *[])
+{
+ //// si->si always true
+ //BOOST_CHECK((bu::base_unit_is_implicitly_convertible<bu::length_base_dimension,bu::si::system_tag,bu::si::system_tag>::value == true));
+ //BOOST_CHECK((bu::base_unit_is_implicitly_convertible<bu::mass_base_dimension,bu::si::system_tag,bu::si::system_tag>::value == true));
+ //BOOST_CHECK((bu::base_unit_is_implicitly_convertible<bu::time_base_dimension,bu::si::system_tag,bu::si::system_tag>::value == true));
+ //BOOST_CHECK((bu::base_unit_is_implicitly_convertible<bu::current_base_dimension,bu::si::system_tag,bu::si::system_tag>::value == true));
+ //BOOST_CHECK((bu::base_unit_is_implicitly_convertible<bu::temperature_base_dimension,bu::si::system_tag,bu::si::system_tag>::value == true));
+ //BOOST_CHECK((bu::base_unit_is_implicitly_convertible<bu::amount_base_dimension,bu::si::system_tag,bu::si::system_tag>::value == true));
+ //BOOST_CHECK((bu::base_unit_is_implicitly_convertible<bu::luminous_intensity_base_dimension,bu::si::system_tag,bu::si::system_tag>::value == true));
+ //BOOST_CHECK((bu::base_unit_is_implicitly_convertible<bu::plane_angle_base_dimension,bu::si::system_tag,bu::si::system_tag>::value == true));
+ //BOOST_CHECK((bu::base_unit_is_implicitly_convertible<bu::solid_angle_base_dimension,bu::si::system_tag,bu::si::system_tag>::value == true));
+
+ //// cgs->cgs always true
+ //BOOST_CHECK((bu::base_unit_is_implicitly_convertible<bu::length_base_dimension,bu::cgs::system_tag,bu::cgs::system_tag>::value == true));
+ //BOOST_CHECK((bu::base_unit_is_implicitly_convertible<bu::mass_base_dimension,bu::cgs::system_tag,bu::cgs::system_tag>::value == true));
+ //BOOST_CHECK((bu::base_unit_is_implicitly_convertible<bu::time_base_dimension,bu::cgs::system_tag,bu::cgs::system_tag>::value == true));
+ //BOOST_CHECK((bu::base_unit_is_implicitly_convertible<bu::current_base_dimension,bu::cgs::system_tag,bu::cgs::system_tag>::value == true));
+ //BOOST_CHECK((bu::base_unit_is_implicitly_convertible<bu::temperature_base_dimension,bu::cgs::system_tag,bu::cgs::system_tag>::value == true));
+ //BOOST_CHECK((bu::base_unit_is_implicitly_convertible<bu::amount_base_dimension,bu::cgs::system_tag,bu::cgs::system_tag>::value == true));
+ //BOOST_CHECK((bu::base_unit_is_implicitly_convertible<bu::luminous_intensity_base_dimension,bu::cgs::system_tag,bu::cgs::system_tag>::value == true));
+ //BOOST_CHECK((bu::base_unit_is_implicitly_convertible<bu::plane_angle_base_dimension,bu::cgs::system_tag,bu::cgs::system_tag>::value == true));
+ //BOOST_CHECK((bu::base_unit_is_implicitly_convertible<bu::solid_angle_base_dimension,bu::cgs::system_tag,bu::cgs::system_tag>::value == true));
+
+ //// si->cgs
+ //BOOST_CHECK((bu::base_unit_is_implicitly_convertible<bu::length_base_dimension,bu::si::system_tag,bu::cgs::system_tag>::value == false));
+ //BOOST_CHECK((bu::base_unit_is_implicitly_convertible<bu::mass_base_dimension,bu::si::system_tag,bu::cgs::system_tag>::value == false));
+ //BOOST_CHECK((bu::base_unit_is_implicitly_convertible<bu::time_base_dimension,bu::si::system_tag,bu::cgs::system_tag>::value == true));
+
+ BOOST_CHECK((bu::is_implicitly_convertible<bu::si::length,bu::cgs::length>::value == false));
+ BOOST_CHECK((bu::is_implicitly_convertible<bu::si::mass,bu::cgs::mass>::value == false));
+ BOOST_CHECK((bu::is_implicitly_convertible<bu::si::time,bu::cgs::time>::value == true));
+
+ BOOST_CHECK((bu::is_implicitly_convertible<bu::si::acceleration,bu::cgs::acceleration>::value == false));
+ BOOST_CHECK((bu::is_implicitly_convertible<bu::si::area,bu::cgs::area>::value == false));
+ BOOST_CHECK((bu::is_implicitly_convertible<bu::si::energy,bu::cgs::energy>::value == false));
+ BOOST_CHECK((bu::is_implicitly_convertible<bu::si::force,bu::cgs::force>::value == false));
+ BOOST_CHECK((bu::is_implicitly_convertible<bu::si::frequency,bu::cgs::frequency>::value == true));
+ BOOST_CHECK((bu::is_implicitly_convertible<bu::si::mass_density,bu::cgs::mass_density>::value == false));
+ BOOST_CHECK((bu::is_implicitly_convertible<bu::si::momentum,bu::cgs::momentum>::value == false));
+ BOOST_CHECK((bu::is_implicitly_convertible<bu::si::power,bu::cgs::power>::value == false));
+ BOOST_CHECK((bu::is_implicitly_convertible<bu::si::pressure,bu::cgs::pressure>::value == false));
+ BOOST_CHECK((bu::is_implicitly_convertible<bu::si::velocity,bu::cgs::velocity>::value == false));
+ BOOST_CHECK((bu::is_implicitly_convertible<bu::si::wavenumber,bu::cgs::wavenumber>::value == false));
+
+ //// cgs->si
+ //BOOST_CHECK((bu::base_unit_is_implicitly_convertible<bu::length_base_dimension,bu::cgs::system_tag,bu::si::system_tag>::value == false));
+ //BOOST_CHECK((bu::base_unit_is_implicitly_convertible<bu::mass_base_dimension,bu::cgs::system_tag,bu::si::system_tag>::value == false));
+ //BOOST_CHECK((bu::base_unit_is_implicitly_convertible<bu::time_base_dimension,bu::cgs::system_tag,bu::si::system_tag>::value == true));
+
+ BOOST_CHECK((bu::is_implicitly_convertible<bu::cgs::length,bu::si::length>::value == false));
+ BOOST_CHECK((bu::is_implicitly_convertible<bu::cgs::mass,bu::si::mass>::value == false));
+ BOOST_CHECK((bu::is_implicitly_convertible<bu::cgs::time,bu::si::time>::value == true));
+
+ BOOST_CHECK((bu::is_implicitly_convertible<bu::cgs::acceleration,bu::si::acceleration>::value == false));
+ BOOST_CHECK((bu::is_implicitly_convertible<bu::cgs::area,bu::si::area>::value == false));
+ BOOST_CHECK((bu::is_implicitly_convertible<bu::cgs::energy,bu::si::energy>::value == false));
+ BOOST_CHECK((bu::is_implicitly_convertible<bu::cgs::force,bu::si::force>::value == false));
+ BOOST_CHECK((bu::is_implicitly_convertible<bu::cgs::frequency,bu::si::frequency>::value == true));
+ BOOST_CHECK((bu::is_implicitly_convertible<bu::cgs::mass_density,bu::si::mass_density>::value == false));
+ BOOST_CHECK((bu::is_implicitly_convertible<bu::cgs::momentum,bu::si::momentum>::value == false));
+ BOOST_CHECK((bu::is_implicitly_convertible<bu::cgs::power,bu::si::power>::value == false));
+ BOOST_CHECK((bu::is_implicitly_convertible<bu::cgs::pressure,bu::si::pressure>::value == false));
+ BOOST_CHECK((bu::is_implicitly_convertible<bu::cgs::velocity,bu::si::velocity>::value == false));
+ BOOST_CHECK((bu::is_implicitly_convertible<bu::cgs::wavenumber,bu::si::wavenumber>::value == false));
+
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<bu::si::time> S1(2.0*bu::si::seconds);
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<bu::cgs::time> S2 = S1;
+
+ BOOST_CHECK((S1.value() == S2.value()));
+
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<bu::si::catalytic_activity> S3(2.0*bu::si::catalytic_activity());
+
+
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<bu::cgs::time> C1(2.0*bu::cgs::seconds);
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<bu::si::time> C2 = C1;
+
+ BOOST_CHECK((C1.value() == C2.value()));
+
+ return 0;
+}
diff --git a/src/boost/libs/units/test/test_information_units.cpp b/src/boost/libs/units/test/test_information_units.cpp
new file mode 100644
index 000000000..80eb04f24
--- /dev/null
+++ b/src/boost/libs/units/test/test_information_units.cpp
@@ -0,0 +1,242 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2014 Erik Erlandson
+//
+// 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)
+
+#include <iostream>
+#include <sstream>
+
+#include <boost/units/quantity.hpp>
+#include <boost/units/conversion.hpp>
+#include <boost/units/io.hpp>
+
+#include <boost/units/systems/si/prefixes.hpp>
+#include <boost/units/systems/si/time.hpp>
+
+// All information systems definitions
+#include <boost/units/systems/information.hpp>
+
+using std::cout;
+using std::cerr;
+using std::endl;
+using std::stringstream;
+
+namespace bu = boost::units;
+namespace si = boost::units::si;
+
+using bu::quantity;
+
+using bu::information::bit_base_unit;
+using bu::information::byte_base_unit;
+using bu::information::nat_base_unit;
+using bu::information::hartley_base_unit;
+using bu::information::shannon_base_unit;
+
+
+#define BOOST_TEST_MAIN
+#include <boost/test/unit_test.hpp>
+
+
+#include <boost/multiprecision/cpp_int.hpp>
+
+const double close_fraction = 0.0000001;
+
+// checks that cf(u2,u1) == expected
+// also checks invariant property that cf(u2,u1) * cf(u1,u2) == 1
+#define CHECK_DIRECT_CF(u1, u2, expected) \
+ BOOST_CHECK_CLOSE_FRACTION(bu::conversion_factor((u2), (u1)), (expected), close_fraction); \
+ BOOST_CHECK_CLOSE_FRACTION(bu::conversion_factor((u2), (u1)) * bu::conversion_factor((u1), (u2)), 1.0, close_fraction);
+
+// check transitive conversion factors
+// invariant: cf(u1,u3) = cf(u1,u2)*cf(u2,u3)
+#define CHECK_TRANSITIVE_CF(u1, u2, u3) { \
+ BOOST_CONSTEXPR_OR_CONST double cf12 = bu::conversion_factor((u2), (u1)) ; \
+ BOOST_CONSTEXPR_OR_CONST double cf23 = bu::conversion_factor((u3), (u2)) ; \
+ BOOST_CONSTEXPR_OR_CONST double cf13 = bu::conversion_factor((u3), (u1)) ; \
+ BOOST_CHECK_CLOSE_FRACTION(cf13, cf12*cf23, close_fraction); \
+ BOOST_CONSTEXPR_OR_CONST double cf32 = bu::conversion_factor((u2), (u3)) ; \
+ BOOST_CONSTEXPR_OR_CONST double cf21 = bu::conversion_factor((u1), (u2)) ; \
+ BOOST_CONSTEXPR_OR_CONST double cf31 = bu::conversion_factor((u1), (u3)) ; \
+ BOOST_CHECK_CLOSE_FRACTION(cf31, cf32*cf21, close_fraction); \
+}
+
+
+BOOST_AUTO_TEST_CASE(test_cf_bit_byte) {
+ CHECK_DIRECT_CF(bit_base_unit::unit_type(), byte_base_unit::unit_type(), 8.0);
+}
+
+BOOST_AUTO_TEST_CASE(test_cf_bit_nat) {
+ CHECK_DIRECT_CF(bit_base_unit::unit_type(), nat_base_unit::unit_type(), 1.442695040888964);
+}
+
+BOOST_AUTO_TEST_CASE(test_cf_bit_hartley) {
+ CHECK_DIRECT_CF(bit_base_unit::unit_type(), hartley_base_unit::unit_type(), 3.321928094887363);
+}
+
+BOOST_AUTO_TEST_CASE(test_cf_bit_shannon) {
+ CHECK_DIRECT_CF(bit_base_unit::unit_type(), shannon_base_unit::unit_type(), 1.0);
+}
+
+/////////////////////////////////////////////////////////////////////////////////////
+// spot-check that these are automatically transitive, thru central "hub unit" bit:
+// basic pattern is to test invariant property: cf(c,a) = cf(c,b)*cf(b,a)
+
+BOOST_AUTO_TEST_CASE(test_transitive_byte_nat) {
+ CHECK_TRANSITIVE_CF(byte_base_unit::unit_type(), bit_base_unit::unit_type(), nat_base_unit::unit_type());
+}
+BOOST_AUTO_TEST_CASE(test_transitive_nat_hartley) {
+ CHECK_TRANSITIVE_CF(nat_base_unit::unit_type(), bit_base_unit::unit_type(), hartley_base_unit::unit_type());
+}
+BOOST_AUTO_TEST_CASE(test_transitive_hartley_shannon) {
+ CHECK_TRANSITIVE_CF(hartley_base_unit::unit_type(), bit_base_unit::unit_type(), shannon_base_unit::unit_type());
+}
+BOOST_AUTO_TEST_CASE(test_transitive_shannon_byte) {
+ CHECK_TRANSITIVE_CF(shannon_base_unit::unit_type(), bit_base_unit::unit_type(), byte_base_unit::unit_type());
+}
+
+// test transitive factors, none of which are bit, just for good measure
+BOOST_AUTO_TEST_CASE(test_transitive_byte_nat_hartley) {
+ CHECK_TRANSITIVE_CF(byte_base_unit::unit_type(), nat_base_unit::unit_type(), hartley_base_unit::unit_type());
+}
+
+BOOST_AUTO_TEST_CASE(test_byte_quantity_is_default) {
+ using namespace bu::information;
+ BOOST_CONSTEXPR_OR_CONST quantity<info, double> qd(2 * byte);
+ BOOST_CHECK_EQUAL(qd.value(), double(2));
+ BOOST_CONSTEXPR_OR_CONST quantity<info, long> ql(2 * byte);
+ BOOST_CHECK_EQUAL(ql.value(), long(2));
+}
+
+BOOST_AUTO_TEST_CASE(test_byte_quantity_explicit) {
+ using namespace bu::information;
+ BOOST_CONSTEXPR_OR_CONST quantity<hu::byte::info, double> qd(2 * byte);
+ BOOST_CHECK_EQUAL(qd.value(), double(2));
+ BOOST_CONSTEXPR_OR_CONST quantity<hu::byte::info, long> ql(2 * byte);
+ BOOST_CHECK_EQUAL(ql.value(), long(2));
+}
+
+BOOST_AUTO_TEST_CASE(test_bit_quantity) {
+ using namespace bu::information;
+ BOOST_CONSTEXPR_OR_CONST quantity<hu::bit::info, double> qd(2 * bit);
+ BOOST_CHECK_EQUAL(qd.value(), double(2));
+ BOOST_CONSTEXPR_OR_CONST quantity<hu::bit::info, long> ql(2 * bit);
+ BOOST_CHECK_EQUAL(ql.value(), long(2));
+}
+
+BOOST_AUTO_TEST_CASE(test_nat_quantity) {
+ using namespace bu::information;
+ BOOST_CONSTEXPR_OR_CONST quantity<hu::nat::info, double> qd(2 * nat);
+ BOOST_CHECK_EQUAL(qd.value(), double(2));
+ BOOST_CONSTEXPR_OR_CONST quantity<hu::nat::info, long> ql(2 * nat);
+ BOOST_CHECK_EQUAL(ql.value(), long(2));
+}
+
+BOOST_AUTO_TEST_CASE(test_hartley_quantity) {
+ using namespace bu::information;
+ BOOST_CONSTEXPR_OR_CONST quantity<hu::hartley::info, double> qd(2 * hartley);
+ BOOST_CHECK_EQUAL(qd.value(), double(2));
+ BOOST_CONSTEXPR_OR_CONST quantity<hu::hartley::info, long> ql(2 * hartley);
+ BOOST_CHECK_EQUAL(ql.value(), long(2));
+}
+
+BOOST_AUTO_TEST_CASE(test_shannon_quantity) {
+ using namespace bu::information;
+ BOOST_CONSTEXPR_OR_CONST quantity<hu::shannon::info, double> qd(2 * shannon);
+ BOOST_CHECK_EQUAL(qd.value(), double(2));
+ BOOST_CONSTEXPR_OR_CONST quantity<hu::shannon::info, long> ql(2 * shannon);
+ BOOST_CHECK_EQUAL(ql.value(), long(2));
+}
+
+BOOST_AUTO_TEST_CASE(test_mixed_hu) {
+ using namespace bu::information;
+ BOOST_CONSTEXPR_OR_CONST double cf = 0.001;
+ BOOST_CHECK_CLOSE_FRACTION((quantity<hu::bit::info>(1.0 * bits)).value(), 1.0, cf);
+ BOOST_CHECK_CLOSE_FRACTION((quantity<hu::byte::info>(1.0 * bits)).value(), 1.0/8.0, cf);
+ BOOST_CHECK_CLOSE_FRACTION((quantity<hu::nat::info>(1.0 * bits)).value(), 0.69315, cf);
+ BOOST_CHECK_CLOSE_FRACTION((quantity<hu::hartley::info>(1.0 * bits)).value(), 0.30102, cf);
+ BOOST_CHECK_CLOSE_FRACTION((quantity<hu::shannon::info>(1.0 * bits)).value(), 1.0, cf);
+}
+
+BOOST_AUTO_TEST_CASE(test_info_prefixes) {
+ using namespace bu::information;
+ BOOST_CONSTEXPR_OR_CONST quantity<info, long long> q10(1LL * kibi * byte);
+ BOOST_CHECK_EQUAL(q10.value(), 1024LL);
+
+ BOOST_CONSTEXPR_OR_CONST quantity<info, long long> q20(1LL * mebi * byte);
+ BOOST_CHECK_EQUAL(q20.value(), 1048576LL);
+
+ BOOST_CONSTEXPR_OR_CONST quantity<info, long long> q30(1LL * gibi * byte);
+ BOOST_CHECK_EQUAL(q30.value(), 1073741824LL);
+
+ BOOST_CONSTEXPR_OR_CONST quantity<info, long long> q40(1LL * tebi * byte);
+ BOOST_CHECK_EQUAL(q40.value(), 1099511627776LL);
+
+ BOOST_CONSTEXPR_OR_CONST quantity<info, long long> q50(1LL * pebi * byte);
+ BOOST_CHECK_EQUAL(q50.value(), 1125899906842624LL);
+
+ BOOST_CONSTEXPR_OR_CONST quantity<info, long long> q60(1LL * exbi * byte);
+ BOOST_CHECK_EQUAL(q60.value(), 1152921504606846976LL);
+
+ using boost::multiprecision::int128_t;
+
+ const quantity<info, int128_t> q70(1LL * zebi * byte);
+ BOOST_CHECK_EQUAL(q70.value(), int128_t("1180591620717411303424"));
+
+ const quantity<info, int128_t> q80(1LL * yobi * byte);
+ BOOST_CHECK_EQUAL(q80.value(), int128_t("1208925819614629174706176"));
+
+ // sanity check: si prefixes should also operate
+ BOOST_CONSTEXPR_OR_CONST quantity<info, long long> q1e3(1LL * si::kilo * byte);
+ BOOST_CHECK_EQUAL(q1e3.value(), 1000LL);
+
+ BOOST_CONSTEXPR_OR_CONST quantity<info, long long> q1e6(1LL * si::mega * byte);
+ BOOST_CHECK_EQUAL(q1e6.value(), 1000000LL);
+}
+
+BOOST_AUTO_TEST_CASE(test_unit_constant_io) {
+ using namespace bu::information;
+
+ std::stringstream ss;
+ ss << bu::symbol_format << bytes;
+ BOOST_CHECK_EQUAL(ss.str(), "B");
+
+ ss.str("");
+ ss << bu::name_format << bytes;
+ BOOST_CHECK_EQUAL(ss.str(), "byte");
+
+ ss.str("");
+ ss << bu::symbol_format << bits;
+ BOOST_CHECK_EQUAL(ss.str(), "b");
+
+ ss.str("");
+ ss << bu::name_format << bits;
+ BOOST_CHECK_EQUAL(ss.str(), "bit");
+
+ ss.str("");
+ ss << bu::symbol_format << nats;
+ BOOST_CHECK_EQUAL(ss.str(), "nat");
+
+ ss.str("");
+ ss << bu::name_format << nats;
+ BOOST_CHECK_EQUAL(ss.str(), "nat");
+
+ ss.str("");
+ ss << bu::symbol_format << hartleys;
+ BOOST_CHECK_EQUAL(ss.str(), "Hart");
+
+ ss.str("");
+ ss << bu::name_format << hartleys;
+ BOOST_CHECK_EQUAL(ss.str(), "hartley");
+
+ ss.str("");
+ ss << bu::symbol_format << shannons;
+ BOOST_CHECK_EQUAL(ss.str(), "Sh");
+
+ ss.str("");
+ ss << bu::name_format << shannons;
+ BOOST_CHECK_EQUAL(ss.str(), "shannon");
+}
diff --git a/src/boost/libs/units/test/test_lambda.cpp b/src/boost/libs/units/test/test_lambda.cpp
new file mode 100644
index 000000000..8c3642c75
--- /dev/null
+++ b/src/boost/libs/units/test/test_lambda.cpp
@@ -0,0 +1,269 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2008 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)
+
+// $Id: test_lambda.cpp 27 2008-06-16 14:50:58Z maehne $
+
+////////////////////////////////////////////////////////////////////////
+///
+/// \file test_lambda.hpp
+///
+/// \brief Unit test for checking the usage of Boost.Units' quantity,
+/// unit, and absolute types in functors created with the
+/// Boost.Lambda library.
+///
+/// \author Torsten Maehne
+/// \date 2008-06-16
+///
+/// This unit test contains a check for each operator action, for
+/// which a specialization of Boost.Lambda's return type deduction
+/// system is made in lambda.hpp, i.e., for the operators defined for
+/// Boost.Units' quantity, unit, and absolute types.
+///
+////////////////////////////////////////////////////////////////////////
+
+#include <boost/function.hpp>
+#include <boost/units/lambda.hpp>
+#include <boost/units/absolute.hpp>
+#include <boost/units/systems/si/temperature.hpp>
+#include "test_header.hpp"
+
+
+namespace bl = boost::lambda;
+namespace bu = boost::units;
+namespace si = boost::units::si;
+
+
+int test_main(int, char *[])
+{
+
+ ////////////////////////////////////////////////////////////////////////
+ // Test for Boost.Lambda working with overloaded operators defined
+ // in <boost/units/quantity.hpp>
+ ////////////////////////////////////////////////////////////////////////
+
+ bu::quantity<bu::length> lvar = 0.0 * bu::meter;
+
+ bu::quantity<bu::dimensionless> dlvar = 3.0;
+
+ // quantity<Unit, Y> += quantity<Unit2, YY>
+ boost::function<bu::quantity<bu::length> (bu::quantity<bu::length>)>
+ f = (bl::var(lvar) += bl::_1);
+
+ lvar = 1.0 * bu::meter;
+ BOOST_CHECK((f(2.0 * bu::meter) == 3.0 * bu::meter));
+ BOOST_CHECK((f(6.0 * bu::meter) == 9.0 * bu::meter));
+
+ // quantity<BOOST_UNITS_DIMENSIONLESS_UNIT(System), Y> += quantity<BOOST_UNITS_DIMENSIONLESS_UNIT(System), Y>
+ dlvar = 4.0;
+ BOOST_CHECK(((bl::var(dlvar) += bl::_1)(3.0) == 7.0));
+
+ // quantity<Unit, Y> -= quantity<Unit2, YY>
+ lvar = 3.0 * bu::meter;
+ BOOST_CHECK((f(-2.0 * bu::meter) == 1.0 * bu::meter));
+ BOOST_CHECK((f(6.0 * bu::meter) == 7.0 * bu::meter));
+
+ // quantity<BOOST_UNITS_DIMENSIONLESS_UNIT(System), Y> -= quantity<BOOST_UNITS_DIMENSIONLESS_UNIT(System), Y>
+ dlvar = 4.0;
+ BOOST_CHECK(((bl::var(dlvar) -= bl::_1)(3.0) == 1.0));
+
+ // quantity<Unit, Y> *= quantity<Unit2, YY>
+ dlvar = 2.0;
+ BOOST_CHECK(((bl::var(dlvar) *= bl::_1)(3.0) == 6.0));
+
+ // quantity<Unit, Y> /= quantity<Unit2, YY>
+ dlvar = 6.0;
+ BOOST_CHECK(((bl::var(dlvar) /= bl::_1)(3.0) == 2.0));
+
+ // quantity<Unit, Y> *= Y
+ lvar = 3.0 * bu::meter;
+ BOOST_CHECK(((bl::var(lvar) *= bl::_1)(2.0) == 6.0 * bu::meter));
+
+ // quantity<Unit, Y> /= Y
+ lvar = 6.0 * bu::meter;
+ BOOST_CHECK(((bl::var(lvar) /= bl::_1)(3.0) == 2.0 * bu::meter));
+
+ // unit<Dim, System> * Y
+ BOOST_CHECK(((bl::_1 * bl::_2)(bu::meter, 2.0) == 2.0 * bu::meter));
+ BOOST_CHECK(((bu::meter * bl::_1)(2.0) == 2.0 * bu::meter));
+
+ // unit<Dim, System> / Y
+ BOOST_CHECK(((bl::_1 / bl::_2)(bu::meter, 0.5) == 2.0 * bu::meter));
+ BOOST_CHECK(((bu::meter / bl::_1)(0.5 * bu::second) == 2.0 * bu::meter_per_second));
+
+ // Y * unit<Dim, System>
+ BOOST_CHECK(((bl::_1 * bl::_2)(2.0, bu::meter) == 2.0 * bu::meter));
+ BOOST_CHECK(((bl::_1 * bu::meter)(2.0 / bu::second) == 2.0 * bu::meter_per_second));
+
+ // Y / unit<Dim, System>
+ BOOST_CHECK(((bl::_1 / bl::_2)(3.5, bu::second) == 3.5 / bu::second));
+ BOOST_CHECK(((bl::_1 / bu::second)(3.5 * bu::meter) == 3.5 * bu::meter_per_second));
+
+ // quantity<Unit, X> * X
+ BOOST_CHECK(((bl::_1 * bl::_2)(2.0, 3.0 * bu::meter) == 6.0 * bu::meter));
+
+ // X * quantity<Unit, X>
+ BOOST_CHECK(((bl::_1 * bl::_2)(4.0 * bu::joule, 2.0) == 8.0 * bu::joule));
+
+ // quantity<Unit, X> / X
+ BOOST_CHECK(((bl::_1 / bl::_2)(4.0 * bu::joule, 2.0) == 2.0 * bu::joule));
+
+ // X / quantity<Unit, X>
+ BOOST_CHECK(((3.0 / bl::_1)(2.0 * bu::second) == 1.5 / bu::second));
+
+ // unit<Dim1, System1> * quantity<Unit2, Y>
+ BOOST_CHECK(((bl::_1 * bl::_2)(bu::meter, 12.0 / bu::second) == 12.0 * bu::meter_per_second));
+ BOOST_CHECK(((bu::meter * bl::_1)(12.0 / bu::second) == 12.0 * bu::meter_per_second));
+
+ // unit<Dim1, System1> / quantity<Unit2, Y>
+ BOOST_CHECK(((bl::_1 / bl::_2)(bu::meter, 0.5 * bu::second) == 2.0 * bu::meter_per_second));
+ BOOST_CHECK(((bu::meter / bl::_1)(0.25 * bu::second) == 4.0 * bu::meter_per_second));
+
+ // quantity<Unit1, Y> * unit<Dim2, System2>
+ BOOST_CHECK(((bl::_1 * bl::_2)(2.0 / bu::second, bu::meter) == 2.0 * bu::meter_per_second));
+ BOOST_CHECK(((bl::_1 * bu::meter)(12.0 / bu::second) == 12.0 * bu::meter_per_second));
+
+ // quantity<Unit1, Y> / unit<Dim2, System2>
+ BOOST_CHECK(((bl::_1 / bl::_2)(3.5 * bu::meter, bu::second) == 3.5 * bu::meter_per_second));
+ BOOST_CHECK(((bl::_1 / bu::second)(5.0 * bu::second) == 5.0));
+
+ // +quantity<Unit, Y>
+ BOOST_CHECK(((+bl::_1)(5.0 * bu::second) == 5.0 * bu::second));
+
+ // -quantity<Unit, Y>
+ BOOST_CHECK(((-bl::_1)(5.0 * bu::second) == -5.0 * bu::second));
+
+ // quantity<Unit1, X> + quantity<Unit2, Y>
+ BOOST_CHECK(((bl::_1 + bl::_2)(2.0 * bu::meter, 4.0 * bu::meter) == 6.0 * bu::meter));
+
+ // quantity<dimensionless, X> + Y
+ BOOST_CHECK(((bl::_1 + 1.0f)(bu::quantity<bu::dimensionless>(2.0)) == 3.0));
+
+ // X + quantity<dimensionless, Y>
+ BOOST_CHECK(((1.0f + bl::_1)(bu::quantity<bu::dimensionless>(1.0)) == 2.0));
+
+ // quantity<Unit1, X> - quantity<Unit2, Y>
+ BOOST_CHECK(((bl::_1 - bl::_2)(2.0 * bu::meter, 4.0 * bu::meter) == -2.0 * bu::meter));
+
+ // quantity<dimensionless, X> - Y
+ BOOST_CHECK(((bl::_1 - 2.0f)(bu::quantity<bu::dimensionless>(1.0)) == -1.0));
+
+ // X - quantity<dimensionless, Y>
+ BOOST_CHECK(((2.0f - bl::_1)(bu::quantity<bu::dimensionless>(1.0)) == 1.0));
+
+ // quantity<Unit1, X> * quantity<Unit2, Y>
+ BOOST_CHECK(((bl::_1 * bl::_2)(2.0 * bu::kilogram, 4.0 * bu::meter_per_second) == 8.0 * bu::kilogram * bu::meter_per_second));
+
+ // quantity<Unit1, X> / quantity<Unit2, Y>
+ BOOST_CHECK(((bl::_1 / bl::_2)(2.0 * bu::meter_per_second, 4.0 * bu::meter_per_second) == 0.5));
+
+ // quantity<Unit, X> == quantity<Unit, Y>
+ BOOST_CHECK(((bl::_1 == bl::_2)(2.0 * bu::meter, 2.0 * bu::meter) == true));
+ BOOST_CHECK(((bl::_1 == bl::_2)(2.0 * bu::meter, 3.0 * bu::meter) == false));
+
+ // quantity<Unit, X> != quantity<Unit, Y>
+ BOOST_CHECK(((bl::_1 != bl::_2)(2.0 * bu::meter, 2.0 * bu::meter) == false));
+ BOOST_CHECK(((bl::_1 != bl::_2)(2.0 * bu::meter, 3.0 * bu::meter) == true));
+
+ // quantity<Unit, X> < quantity<Unit, Y>
+ BOOST_CHECK(((bl::_1 < bl::_2)(2.0 * bu::meter, 2.0 * bu::meter) == false));
+ BOOST_CHECK(((bl::_1 < bl::_2)(2.0 * bu::meter, 3.0 * bu::meter) == true));
+
+ // quantity<Unit, X> <= quantity<Unit, Y>
+ BOOST_CHECK(((bl::_1 <= bl::_2)(2.0 * bu::meter, 2.0 * bu::meter) == true));
+ BOOST_CHECK(((bl::_1 <= bl::_2)(2.0 * bu::meter, 3.0 * bu::meter) == true));
+ BOOST_CHECK(((bl::_1 <= bl::_2)(4.0 * bu::meter, 3.0 * bu::meter) == false));
+
+ // quantity<Unit, X> > quantity<Unit, Y>
+ BOOST_CHECK(((bl::_1 > bl::_2)(2.0 * bu::meter, 2.0 * bu::meter) == false));
+ BOOST_CHECK(((bl::_1 > bl::_2)(2.0 * bu::meter, 3.0 * bu::meter) == false));
+ BOOST_CHECK(((bl::_1 > bl::_2)(4.0 * bu::meter, 3.0 * bu::meter) == true));
+
+ // quantity<Unit, X> >= quantity<Unit, Y>
+ BOOST_CHECK(((bl::_1 >= bl::_2)(2.0 * bu::meter, 2.0 * bu::meter) == true));
+ BOOST_CHECK(((bl::_1 >= bl::_2)(2.0 * bu::meter, 3.0 * bu::meter) == false));
+ BOOST_CHECK(((bl::_1 >= bl::_2)(4.0 * bu::meter, 3.0 * bu::meter) == true));
+
+
+ ////////////////////////////////////////////////////////////////////////
+ // Test for Boost.Lambda working with overloaded operators defined
+ // in <boost/units/unit.hpp>
+ ////////////////////////////////////////////////////////////////////////
+
+ // +unit<Dim, System>
+ BOOST_CHECK(((+bl::_1)(bu::meter) == bu::meter));
+
+ // -unit<Dim, System>
+ BOOST_CHECK(((-bl::_1)(bu::meter) == bu::meter));
+
+ // unit<Dim1, System1> + unit<Dim2, System2>
+ BOOST_CHECK(((bl::_1 + bu::meter)(bu::meter) == bu::meter));
+ BOOST_CHECK(((bu::meter + bl::_1)(bu::meter) == bu::meter));
+ BOOST_CHECK(((bl::_1 + bl::_2)(bu::meter, bu::meter) == bu::meter));
+
+ // unit<Dim1, System1> - unit<Dim2, System2>
+ BOOST_CHECK(((bl::_1 - bl::_2)(bu::meter, bu::meter) == bu::meter));
+ BOOST_CHECK(((bl::_1 - bu::meter)(bu::meter) == bu::meter));
+ BOOST_CHECK(((bu::meter - bl::_1)(bu::meter) == bu::meter));
+
+ // unit<Dim1, System1> * unit<Dim2, System2>
+ BOOST_CHECK(((bl::_1 * bl::_2)(bu::meter, bu::meter) == bu::meter * bu::meter));
+ BOOST_CHECK(((bl::_1 * bu::meter)(bu::meter) == bu::meter * bu::meter));
+
+ // unit<Dim1, System1> / unit<Dim2, System2>
+ BOOST_CHECK(((bl::_1 / bl::_2)(bu::meter, bu::second) == bu::meter_per_second));
+ BOOST_CHECK(((bl::_1 / bu::second)(bu::meter) == bu::meter_per_second));
+
+ // unit<Dim1, System1> == unit<Dim2, System2>
+ BOOST_CHECK(((bl::_1 == bu::meter)(bu::meter) == true));
+ BOOST_CHECK(((bl::_1 == bu::meter)(bu::second) == false));
+
+ // unit<Dim1, System1> != unit<Dim2, System2>
+ BOOST_CHECK(((bl::_1 != bu::meter)(bu::meter) == false));
+ BOOST_CHECK(((bl::_1 != bu::meter)(bu::second) == true));
+
+
+ ////////////////////////////////////////////////////////////////////////
+ // Test for Boost.Lambda working with overloaded operators defined
+ // in <boost/units/absolute.hpp>
+ ////////////////////////////////////////////////////////////////////////
+
+ // absolute<Y> += Y
+ bu::quantity<bu::absolute<si::temperature> > Ta = 270.0 * bu::absolute<si::temperature>();
+ (Ta += bl::_1)(30.0 * si::kelvin);
+ BOOST_CHECK(( Ta == 300.0 * bu::absolute<si::temperature>()));
+
+ // absolute<Y> -= Y
+ Ta = 270 * bu::absolute<si::temperature>();
+ (Ta -= bl::_1)(-30.0 * si::kelvin);
+ BOOST_CHECK(( Ta == 300.0 * bu::absolute<si::temperature>()));
+
+ // absolute<Y> + Y
+ BOOST_CHECK(((270.0 * bu::absolute<si::temperature>() + bl::_1)(30.0 * si::kelvin) == 300.0 * bu::absolute<si::temperature>()));
+
+ // Y + absolute<Y>
+ BOOST_CHECK(((bl::_1 + 270.0 * bu::absolute<si::temperature>())(30.0 * si::kelvin) == 300.0 * bu::absolute<si::temperature>()));
+
+ // absolute<Y> - Y
+ BOOST_CHECK(((270.0 * bu::absolute<si::temperature>() - bl::_1)(30.0 * si::kelvin) == 240.0 * bu::absolute<si::temperature>()));
+
+ // absolute<Y> - absolute<Y>
+ BOOST_CHECK(((bl::_1 - 270.0 * bu::absolute<si::temperature>())(300.0 * bu::absolute<si::temperature>()) == 30.0 * si::kelvin));
+
+ // T * absolute<unit<D, S> >
+ BOOST_CHECK(((bl::_1 * bu::absolute<si::temperature>())(300.0) == 300.0 * bu::absolute<si::temperature>()));
+ BOOST_CHECK(((bl::_1 * bl::_2)(300.0, bu::absolute<si::temperature>()) == 300.0 * bu::absolute<si::temperature>()));
+
+ // absolute<unit<D, S> > * T
+ BOOST_CHECK(((bu::absolute<si::temperature>() * bl::_1)(300.0) == 300.0 * bu::absolute<si::temperature>()));
+ BOOST_CHECK(((bl::_1 * bl::_2)(bu::absolute<si::temperature>(), 300.0) == 300.0 * bu::absolute<si::temperature>()));
+
+
+ return 0;
+}
diff --git a/src/boost/libs/units/test/test_limits.cpp b/src/boost/libs/units/test/test_limits.cpp
new file mode 100644
index 000000000..6057cf94d
--- /dev/null
+++ b/src/boost/libs/units/test/test_limits.cpp
@@ -0,0 +1,127 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2008 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)
+
+/**
+\file
+
+\brief test_limits.cpp
+
+\details
+Test numeric_limits specialization.
+
+Output:
+@verbatim
+@endverbatim
+**/
+
+#include <complex>
+#include <limits>
+
+#include <boost/units/limits.hpp>
+#include <boost/units/cmath.hpp>
+
+#include "test_header.hpp"
+
+typedef boost::units::length unit_type;
+using boost::units::quantity;
+
+template<bool>
+struct check_quiet_NaN;
+
+template<>
+struct check_quiet_NaN<true> {
+ template<class T>
+ static void apply() {
+ quantity<unit_type, T> q((std::numeric_limits<quantity<unit_type, T> >::quiet_NaN)());
+ bool test = isnan BOOST_PREVENT_MACRO_SUBSTITUTION (q);
+ BOOST_CHECK(test);
+ }
+};
+
+template<>
+struct check_quiet_NaN<false> {
+ template<class T>
+ static void apply() {}
+};
+
+template<bool>
+struct check_signaling_NaN;
+
+template<>
+struct check_signaling_NaN<true> {
+ template<class T>
+ static void apply() {
+ quantity<unit_type, T> q((std::numeric_limits<quantity<unit_type, T> >::signaling_NaN)());
+ bool test = isnan BOOST_PREVENT_MACRO_SUBSTITUTION (q);
+ BOOST_CHECK(test);
+ }
+};
+
+template<>
+struct check_signaling_NaN<false> {
+ template<class T>
+ static void apply() {}
+};
+
+template<class T>
+void do_check() {
+ #define CHECK_FUNCTION(name) BOOST_CHECK(((std::numeric_limits<T>::name)() == (std::numeric_limits<quantity<unit_type, T> >::name)().value()))
+ #define CHECK_CONSTANT(name) BOOST_CHECK((std::numeric_limits<T>::name == std::numeric_limits<quantity<unit_type, T> >::name))
+ CHECK_FUNCTION(min);
+ CHECK_FUNCTION(max);
+ CHECK_FUNCTION(epsilon);
+ CHECK_FUNCTION(round_error);
+ CHECK_FUNCTION(infinity);
+ CHECK_FUNCTION(denorm_min);
+ #ifndef BOOST_NO_CXX11_NUMERIC_LIMITS
+ CHECK_FUNCTION(lowest);
+ #endif
+
+ CHECK_CONSTANT(is_specialized);
+ CHECK_CONSTANT(digits);
+ CHECK_CONSTANT(digits10);
+ #ifndef BOOST_NO_CXX11_NUMERIC_LIMITS
+ CHECK_CONSTANT(max_digits10);
+ #endif
+ CHECK_CONSTANT(is_signed);
+ CHECK_CONSTANT(is_integer);
+ CHECK_CONSTANT(is_exact);
+ CHECK_CONSTANT(radix);
+ CHECK_CONSTANT(min_exponent);
+ CHECK_CONSTANT(min_exponent10);
+ CHECK_CONSTANT(max_exponent);
+ CHECK_CONSTANT(max_exponent10);
+ CHECK_CONSTANT(has_infinity);
+ CHECK_CONSTANT(has_quiet_NaN);
+ CHECK_CONSTANT(has_signaling_NaN);
+ CHECK_CONSTANT(has_denorm);
+ CHECK_CONSTANT(has_denorm_loss);
+ CHECK_CONSTANT(is_iec559);
+ CHECK_CONSTANT(is_bounded);
+ CHECK_CONSTANT(is_modulo);
+ CHECK_CONSTANT(traps);
+ CHECK_CONSTANT(tinyness_before);
+ CHECK_CONSTANT(round_style);
+
+ check_quiet_NaN<std::numeric_limits<quantity<unit_type, T> >::has_quiet_NaN>::template apply<T>();
+ check_signaling_NaN<std::numeric_limits<quantity<unit_type, T> >::has_signaling_NaN>::template apply<T>();
+}
+
+int test_main(int,char *[])
+{
+ do_check<float>();
+ do_check<double>();
+ do_check<int>();
+ do_check<long>();
+ do_check<unsigned>();
+ do_check<std::complex<double> >();
+
+ return(0);
+}
diff --git a/src/boost/libs/units/test/test_mixed_value_types.cpp b/src/boost/libs/units/test/test_mixed_value_types.cpp
new file mode 100644
index 000000000..7d86362c7
--- /dev/null
+++ b/src/boost/libs/units/test/test_mixed_value_types.cpp
@@ -0,0 +1,22 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2007-2008 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)
+
+#include <boost/units/quantity.hpp>
+#include <boost/units/unit.hpp>
+#include <boost/units/systems/si/length.hpp>
+
+namespace bu = boost::units;
+
+int main() {
+ bu::quantity<bu::si::length, double> q1;
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<bu::si::length, int> q2;
+ q1 + q2;
+ q1 -= q2;
+}
diff --git a/src/boost/libs/units/test/test_negative_denominator.cpp b/src/boost/libs/units/test/test_negative_denominator.cpp
new file mode 100644
index 000000000..e9b638abc
--- /dev/null
+++ b/src/boost/libs/units/test/test_negative_denominator.cpp
@@ -0,0 +1,32 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2008 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)
+
+/**
+\file
+
+\brief test_negative_denominator.cpp
+
+\details
+Test negative denominator for static_rational class.
+
+Output:
+@verbatim
+@endverbatim
+**/
+
+#include <boost/units/static_rational.hpp>
+
+#include <boost/mpl/assert.hpp>
+#include <boost/type_traits/is_same.hpp>
+
+BOOST_MPL_ASSERT((boost::is_same<boost::units::static_rational<-2,1>::type, boost::units::static_rational<2, -1>::type>));
+
+int main() {
+}
diff --git a/src/boost/libs/units/test/test_output.cpp b/src/boost/libs/units/test/test_output.cpp
new file mode 100644
index 000000000..abc39d858
--- /dev/null
+++ b/src/boost/libs/units/test/test_output.cpp
@@ -0,0 +1,499 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2009 Steven Watanabe
+// Copyright Paul A. Bristow 2010
+//
+// 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)
+
+/**
+\file test_output.cpp
+
+\brief
+Test unit and quantity printing
+\details
+Tests for output from various units, name, symbol and raw formats, and automatic prefixing in engineering and binary units.
+**/
+
+#include <boost/units/quantity.hpp>
+#include <boost/units/io.hpp>
+#include <boost/units/unit.hpp>
+#include <boost/units/scale.hpp>
+#include <boost/units/scaled_base_unit.hpp>
+#include <boost/units/make_scaled_unit.hpp>
+#include <boost/units/base_unit.hpp>
+#include <boost/units/make_system.hpp>
+#include <boost/units/absolute.hpp>
+#include <boost/units/physical_dimensions/length.hpp>
+#include <boost/units/physical_dimensions/time.hpp>
+#include <boost/units/physical_dimensions/velocity.hpp>
+#include <boost/units/physical_dimensions/volume.hpp>
+#include <boost/units/physical_dimensions/acceleration.hpp>
+#include <boost/units/physical_dimensions/area.hpp>
+
+#include <boost/regex.hpp>
+
+#include <iostream>
+#include <sstream>
+#include <boost/config.hpp>
+#include <limits>
+
+#define BOOST_TEST_MAIN
+#include <boost/test/unit_test.hpp>
+
+struct meter_base_unit : boost::units::base_unit<meter_base_unit, boost::units::length_dimension, 1> {
+ static BOOST_CONSTEXPR const char* name() { return("meter"); }
+ static BOOST_CONSTEXPR const char* symbol() { return("m"); }
+};
+
+struct second_base_unit : boost::units::base_unit<second_base_unit, boost::units::time_dimension, 2> {
+ static BOOST_CONSTEXPR const char* name() { return("second"); }
+ static BOOST_CONSTEXPR const char* symbol() { return("s"); }
+};
+
+struct byte_base_unit : boost::units::base_unit<byte_base_unit, boost::units::dimensionless_type, 3> {
+ static BOOST_CONSTEXPR const char* name() { return("byte"); }
+ static BOOST_CONSTEXPR const char* symbol() { return("b"); }
+};
+
+typedef boost::units::make_system<meter_base_unit, second_base_unit>::type my_system;
+
+typedef boost::units::unit<boost::units::length_dimension, my_system> length;
+typedef boost::units::unit<boost::units::velocity_dimension, my_system> velocity;
+
+typedef boost::units::make_scaled_unit<length, boost::units::scale<10, boost::units::static_rational<3> > >::type scaled_length;
+typedef boost::units::make_scaled_unit<velocity, boost::units::scale<10, boost::units::static_rational<3> > >::type scaled_velocity1;
+
+typedef boost::units::scaled_base_unit<second_base_unit, boost::units::scale<10, boost::units::static_rational<-3> > > millisecond_base_unit;
+
+typedef boost::units::make_system<meter_base_unit, millisecond_base_unit>::type scaled_system;
+
+typedef boost::units::unit<boost::units::time_dimension, scaled_system> scaled_time;
+typedef boost::units::unit<boost::units::velocity_dimension, scaled_system> scaled_velocity2;
+
+typedef boost::units::unit<boost::units::area_dimension, my_system> area;
+typedef boost::units::make_scaled_unit<area, boost::units::scale<10, boost::units::static_rational<3> > >::type scaled_area;
+
+typedef boost::units::make_scaled_unit<scaled_length, boost::units::scale<2, boost::units::static_rational<10> > >::type double_scaled_length;
+
+typedef boost::units::scaled_base_unit<meter_base_unit, boost::units::scale<100, boost::units::static_rational<1> > > scaled_length_base_unit;
+namespace boost {
+namespace units {
+template<>
+struct base_unit_info<scaled_length_base_unit> {
+ static BOOST_CONSTEXPR const char* symbol() { return("scm"); }
+ static BOOST_CONSTEXPR const char* name() { return("scaled_meter"); }
+};
+}
+}
+typedef boost::units::scaled_base_unit<scaled_length_base_unit, boost::units::scale<10, boost::units::static_rational<3> > > double_scaled_length_base_unit;
+typedef double_scaled_length_base_unit::unit_type double_scaled_length2;
+
+typedef boost::units::reduce_unit<boost::units::unit<boost::units::volume_dimension, my_system> >::type custom1;
+
+std::string name_string(const custom1&) { return("custom1"); }
+std::string symbol_string(const custom1&) { return("c1"); }
+
+typedef boost::units::reduce_unit<boost::units::unit<boost::units::acceleration_dimension, my_system> >::type custom2;
+
+BOOST_CONSTEXPR const char* name_string(const custom2&) { return("custom2"); }
+BOOST_CONSTEXPR const char* symbol_string(const custom2&) { return("c2"); }
+
+typedef boost::units::make_scaled_unit<custom1, boost::units::scale<10, boost::units::static_rational<3> > >::type scaled_custom1;
+typedef boost::units::make_scaled_unit<custom2, boost::units::scale<10, boost::units::static_rational<3> > >::type scaled_custom2;
+
+#ifndef BOOST_NO_CWCHAR
+
+#define BOOST_UNITS_TEST_OUTPUT(v, expected) \
+{ \
+ std::ostringstream ss; \
+ ss FORMATTERS << v; \
+ BOOST_CHECK_EQUAL(ss.str(), expected); \
+} \
+{ \
+ std::wostringstream ss; \
+ ss FORMATTERS << v; \
+ BOOST_CHECK(ss.str() == BOOST_PP_CAT(L, expected)); \
+}
+
+#define BOOST_UNITS_TEST_OUTPUT_REGEX(v, expected) \
+{ \
+ std::ostringstream ss; \
+ ss FORMATTERS << v; \
+ boost::regex r(expected); \
+ BOOST_CHECK_MESSAGE(boost::regex_match(ss.str(), r), \
+ ss.str() + " does not match " + expected); \
+} \
+{ \
+ std::wostringstream ss; \
+ ss FORMATTERS << v; \
+ boost::wregex r(BOOST_PP_CAT(L, expected)); \
+ BOOST_CHECK(boost::regex_match(ss.str(), r)); \
+}
+
+#define BOOST_UNITS_TEST_OUTPUT_DISPLAY(v) \
+{ \
+ std::ostringstream ss; \
+ ss FORMATTERS << v; \
+ std::cout << #v << ": " << ss.str() << std::endl; \
+} \
+{ \
+ std::wostringstream ss; \
+ ss FORMATTERS << v; \
+ std::wcout << #v << ": " << ss.str() << std::endl; \
+}
+
+#else
+
+#define BOOST_UNITS_TEST_OUTPUT(v, expected) \
+{ \
+ std::ostringstream ss; \
+ ss FORMATTERS << v; \
+ BOOST_CHECK_EQUAL(ss.str(), expected); \
+}
+
+#define BOOST_UNITS_TEST_OUTPUT_REGEX(v, expected) \
+{ \
+ std::ostringstream ss; \
+ ss FORMATTERS << v; \
+ boost::regex r(expected); \
+ BOOST_CHECK_MESSAGE(boost::regex_match(ss.str(), r), \
+ ss.str() + " does not match " + expected); \
+}
+
+#define BOOST_UNITS_TEST_OUTPUT_DISPLAY(v) \
+{ \
+ std::ostringstream ss; \
+ ss FORMATTERS << v; \
+ std::cout << #v << ": " << ss.str() << std::endl; \
+}
+
+#endif
+
+BOOST_AUTO_TEST_CASE(test_output_unit_symbol)
+{ // base units using default symbol_format (no format specified) and no auto prefixing.
+#define FORMATTERS
+ BOOST_UNITS_TEST_OUTPUT(meter_base_unit::unit_type(), "m");
+ BOOST_UNITS_TEST_OUTPUT(velocity(), "m s^-1");
+ BOOST_UNITS_TEST_OUTPUT(scaled_length(), "km");
+ BOOST_UNITS_TEST_OUTPUT(scaled_velocity1(), "k(m s^-1)");
+ BOOST_UNITS_TEST_OUTPUT(millisecond_base_unit::unit_type(), "ms");
+ BOOST_UNITS_TEST_OUTPUT(scaled_time(), "ms");
+ BOOST_UNITS_TEST_OUTPUT(scaled_velocity2(), "m ms^-1");
+ BOOST_UNITS_TEST_OUTPUT(area(), "m^2");
+ BOOST_UNITS_TEST_OUTPUT(scaled_area(), "k(m^2)");
+ BOOST_UNITS_TEST_OUTPUT(double_scaled_length(), "Kikm");
+ BOOST_UNITS_TEST_OUTPUT(double_scaled_length2(), "kscm");
+ BOOST_UNITS_TEST_OUTPUT(custom1(), "c1");
+ BOOST_UNITS_TEST_OUTPUT(custom2(), "c2");
+ BOOST_UNITS_TEST_OUTPUT(scaled_custom1(), "kc1");
+ BOOST_UNITS_TEST_OUTPUT(scaled_custom2(), "kc2");
+ BOOST_UNITS_TEST_OUTPUT(boost::units::absolute<meter_base_unit::unit_type>(), "absolute m");
+#undef FORMATTERS
+}
+
+BOOST_AUTO_TEST_CASE(test_output_unit_raw)
+{ // raw format specified
+#define FORMATTERS << boost::units::raw_format
+ BOOST_UNITS_TEST_OUTPUT(meter_base_unit::unit_type(), "m");
+ BOOST_UNITS_TEST_OUTPUT(velocity(), "m s^-1");
+ BOOST_UNITS_TEST_OUTPUT(scaled_length(), "km");
+ BOOST_UNITS_TEST_OUTPUT(scaled_velocity1(), "k(m s^-1)");
+ BOOST_UNITS_TEST_OUTPUT(millisecond_base_unit::unit_type(), "ms");
+ BOOST_UNITS_TEST_OUTPUT(scaled_time(), "ms");
+ BOOST_UNITS_TEST_OUTPUT(scaled_velocity2(), "m ms^-1");
+ BOOST_UNITS_TEST_OUTPUT(area(), "m^2");
+ BOOST_UNITS_TEST_OUTPUT(scaled_area(), "k(m^2)");
+ BOOST_UNITS_TEST_OUTPUT(double_scaled_length(), "Kikm");
+ BOOST_UNITS_TEST_OUTPUT(double_scaled_length2(), "kscm");
+ // when using raw format, we ignore the user defined overloads
+ BOOST_UNITS_TEST_OUTPUT(custom1(), "m^3");
+ BOOST_UNITS_TEST_OUTPUT(custom2(), "m s^-2");
+ BOOST_UNITS_TEST_OUTPUT(scaled_custom1(), "k(m^3)");
+ BOOST_UNITS_TEST_OUTPUT(scaled_custom2(), "k(m s^-2)");
+ BOOST_UNITS_TEST_OUTPUT(boost::units::absolute<meter_base_unit::unit_type>(), "absolute m");
+#undef FORMATTERS
+}
+
+BOOST_AUTO_TEST_CASE(test_output_unit_name)
+{ // name format specified.
+#define FORMATTERS << boost::units::name_format
+ BOOST_UNITS_TEST_OUTPUT(meter_base_unit::unit_type(), "meter");
+ BOOST_UNITS_TEST_OUTPUT(velocity(), "meter second^-1");
+ BOOST_UNITS_TEST_OUTPUT(scaled_length(), "kilometer");
+ BOOST_UNITS_TEST_OUTPUT(scaled_velocity1(), "kilo(meter second^-1)");
+ BOOST_UNITS_TEST_OUTPUT(millisecond_base_unit::unit_type(), "millisecond");
+ BOOST_UNITS_TEST_OUTPUT(scaled_time(), "millisecond");
+ BOOST_UNITS_TEST_OUTPUT(scaled_velocity2(), "meter millisecond^-1");
+ BOOST_UNITS_TEST_OUTPUT(area(), "meter^2");
+ BOOST_UNITS_TEST_OUTPUT(scaled_area(), "kilo(meter^2)");
+ BOOST_UNITS_TEST_OUTPUT(double_scaled_length(), "kibikilometer");
+ BOOST_UNITS_TEST_OUTPUT(double_scaled_length2(), "kiloscaled_meter");
+ BOOST_UNITS_TEST_OUTPUT(custom1(), "custom1");
+ BOOST_UNITS_TEST_OUTPUT(custom2(), "custom2");
+ BOOST_UNITS_TEST_OUTPUT(scaled_custom1(), "kilocustom1");
+ BOOST_UNITS_TEST_OUTPUT(scaled_custom2(), "kilocustom2");
+ BOOST_UNITS_TEST_OUTPUT(boost::units::absolute<meter_base_unit::unit_type>(), "absolute meter");
+#undef FORMATTERS
+}
+
+
+BOOST_AUTO_TEST_CASE(test_output_quantity_symbol)
+{ // quantity symbols using default format.
+#define FORMATTERS
+ BOOST_UNITS_TEST_OUTPUT(1.5*meter_base_unit::unit_type(), "1.5 m");
+ BOOST_UNITS_TEST_OUTPUT(1.5*velocity(), "1.5 m s^-1");
+ BOOST_UNITS_TEST_OUTPUT(1.5*scaled_length(), "1.5 km");
+ BOOST_UNITS_TEST_OUTPUT(1.5*scaled_velocity1(), "1.5 k(m s^-1)");
+ BOOST_UNITS_TEST_OUTPUT(1.5*millisecond_base_unit::unit_type(), "1.5 ms");
+ BOOST_UNITS_TEST_OUTPUT(1.5*scaled_time(), "1.5 ms");
+ BOOST_UNITS_TEST_OUTPUT(1.5*scaled_velocity2(), "1.5 m ms^-1");
+ BOOST_UNITS_TEST_OUTPUT(1.5*area(), "1.5 m^2");
+ BOOST_UNITS_TEST_OUTPUT(1.5*scaled_area(), "1.5 k(m^2)");
+ BOOST_UNITS_TEST_OUTPUT(1.5*double_scaled_length(), "1.5 Kikm");
+ BOOST_UNITS_TEST_OUTPUT(1.5*double_scaled_length2(), "1.5 kscm");
+ BOOST_UNITS_TEST_OUTPUT(1.5*custom1(), "1.5 c1");
+ BOOST_UNITS_TEST_OUTPUT(1.5*custom2(), "1.5 c2");
+ BOOST_UNITS_TEST_OUTPUT(1.5*scaled_custom1(), "1.5 kc1");
+ BOOST_UNITS_TEST_OUTPUT(1.5*scaled_custom2(), "1.5 kc2");
+ BOOST_UNITS_TEST_OUTPUT(1.5*boost::units::absolute<meter_base_unit::unit_type>(), "1.5 absolute m");
+ BOOST_UNITS_TEST_OUTPUT(std::pow(2., 10) * byte_base_unit::unit_type(), "1024 b");
+
+#undef FORMATTERS
+}
+
+BOOST_AUTO_TEST_CASE(test_output_quantity_raw)
+{ // quantity symbols using raw format.
+#define FORMATTERS << boost::units::raw_format
+ BOOST_UNITS_TEST_OUTPUT(1.5*meter_base_unit::unit_type(), "1.5 m");
+ BOOST_UNITS_TEST_OUTPUT(1.5*velocity(), "1.5 m s^-1");
+ BOOST_UNITS_TEST_OUTPUT(1.5*scaled_length(), "1.5 km");
+ BOOST_UNITS_TEST_OUTPUT(1.5*scaled_velocity1(), "1.5 k(m s^-1)");
+ BOOST_UNITS_TEST_OUTPUT(1.5*millisecond_base_unit::unit_type(), "1.5 ms");
+ BOOST_UNITS_TEST_OUTPUT(1.5*scaled_time(), "1.5 ms");
+ BOOST_UNITS_TEST_OUTPUT(1.5*scaled_velocity2(), "1.5 m ms^-1");
+ BOOST_UNITS_TEST_OUTPUT(1.5*area(), "1.5 m^2");
+ BOOST_UNITS_TEST_OUTPUT(1.5*scaled_area(), "1.5 k(m^2)");
+ BOOST_UNITS_TEST_OUTPUT(1.5*double_scaled_length(), "1.5 Kikm");
+ BOOST_UNITS_TEST_OUTPUT(1.5*double_scaled_length2(), "1.5 kscm");
+ // when using raw format, we ignore the user defined overloads
+ BOOST_UNITS_TEST_OUTPUT(1.5*custom1(), "1.5 m^3");
+ BOOST_UNITS_TEST_OUTPUT(1.5*custom2(), "1.5 m s^-2");
+ BOOST_UNITS_TEST_OUTPUT(1.5*scaled_custom1(), "1.5 k(m^3)");
+ BOOST_UNITS_TEST_OUTPUT(1.5*scaled_custom2(), "1.5 k(m s^-2)");
+ BOOST_UNITS_TEST_OUTPUT(1.5*boost::units::absolute<meter_base_unit::unit_type>(), "1.5 absolute m");
+#undef FORMATTERS
+}
+
+BOOST_AUTO_TEST_CASE(test_output_quantity_name)
+{ // // quantity symbols using name format.
+#define FORMATTERS << boost::units::name_format
+ BOOST_UNITS_TEST_OUTPUT(1.5*meter_base_unit::unit_type(), "1.5 meter");
+ BOOST_UNITS_TEST_OUTPUT(1.5*velocity(), "1.5 meter second^-1");
+ BOOST_UNITS_TEST_OUTPUT(1.5*scaled_length(), "1.5 kilometer");
+ BOOST_UNITS_TEST_OUTPUT(1.5*scaled_velocity1(), "1.5 kilo(meter second^-1)");
+ BOOST_UNITS_TEST_OUTPUT(1.5*millisecond_base_unit::unit_type(), "1.5 millisecond");
+ BOOST_UNITS_TEST_OUTPUT(1.5*scaled_time(), "1.5 millisecond");
+ BOOST_UNITS_TEST_OUTPUT(1.5*scaled_velocity2(), "1.5 meter millisecond^-1");
+ BOOST_UNITS_TEST_OUTPUT(1.5*area(), "1.5 meter^2");
+ BOOST_UNITS_TEST_OUTPUT(1.5*scaled_area(), "1.5 kilo(meter^2)");
+ BOOST_UNITS_TEST_OUTPUT(1.5*double_scaled_length(), "1.5 kibikilometer");
+ BOOST_UNITS_TEST_OUTPUT(1.5*double_scaled_length2(), "1.5 kiloscaled_meter");
+ BOOST_UNITS_TEST_OUTPUT(1.5*custom1(), "1.5 custom1");
+ BOOST_UNITS_TEST_OUTPUT(1.5*custom2(), "1.5 custom2");
+ BOOST_UNITS_TEST_OUTPUT(1.5*scaled_custom1(), "1.5 kilocustom1");
+ BOOST_UNITS_TEST_OUTPUT(1.5*scaled_custom2(), "1.5 kilocustom2");
+ BOOST_UNITS_TEST_OUTPUT(1.5*boost::units::absolute<meter_base_unit::unit_type>(), "1.5 absolute meter");
+#undef FORMATTERS
+}
+
+BOOST_AUTO_TEST_CASE(test_output_autoprefixed_quantity_name)
+{ // Engineering autoprefix, with name format.
+#define FORMATTERS << boost::units::name_format << boost::units::engineering_prefix
+ // Single base unit like meter.
+ BOOST_UNITS_TEST_OUTPUT(1.5*meter_base_unit::unit_type(), "1.5 meter");
+ BOOST_UNITS_TEST_OUTPUT(1500.0*meter_base_unit::unit_type(), "1.5 kilometer");
+ BOOST_UNITS_TEST_OUTPUT(1.5e7*meter_base_unit::unit_type(), "15 megameter");
+ BOOST_UNITS_TEST_OUTPUT(1.5e-3*meter_base_unit::unit_type(), "1.5 millimeter");
+ BOOST_UNITS_TEST_OUTPUT(1.5e-9*meter_base_unit::unit_type(), "1.5 nanometer");
+ BOOST_UNITS_TEST_OUTPUT(1.5e-8*meter_base_unit::unit_type(), "15 nanometer");
+ BOOST_UNITS_TEST_OUTPUT(1.5e-10*meter_base_unit::unit_type(), "150 picometer");
+ BOOST_UNITS_TEST_OUTPUT(0.0000000012345 * meter_base_unit::unit_type(), "1.2345 nanometer");
+
+ // Too small or large for a multiple name.
+ BOOST_UNITS_TEST_OUTPUT_REGEX(9.99999e-25 * meter_base_unit::unit_type(), "9\\.99999e-0?25 meter"); // Just too small for multiple.
+ BOOST_UNITS_TEST_OUTPUT_REGEX(1e+28 * meter_base_unit::unit_type(), "1e\\+0?28 meter"); // Just too large for multiple.
+ BOOST_UNITS_TEST_OUTPUT_REGEX(1.5e-25 * meter_base_unit::unit_type(), "1\\.5e-0?25 meter"); // Too small for multiple.
+ BOOST_UNITS_TEST_OUTPUT_REGEX(1.5e+28 * meter_base_unit::unit_type(), "1\\.5e\\+0?28 meter"); // Too large for multiple.
+ // Too 'biggest or too smallest'.
+ BOOST_UNITS_TEST_OUTPUT_REGEX((std::numeric_limits<float>::max)()*meter_base_unit::unit_type(), "3\\.40282e\\+0?38 meter");
+ BOOST_UNITS_TEST_OUTPUT_REGEX((std::numeric_limits<float>::min)()*meter_base_unit::unit_type(), "1\\.17549e-0?38 meter");
+ BOOST_UNITS_TEST_OUTPUT((std::numeric_limits<double>::max)()*meter_base_unit::unit_type(), "1.79769e+308 meter");
+ BOOST_UNITS_TEST_OUTPUT((std::numeric_limits<double>::min)()*meter_base_unit::unit_type(), "2.22507e-308 meter");
+ // Infinity and NaN
+ BOOST_UNITS_TEST_OUTPUT_REGEX(std::numeric_limits<float>::infinity()*meter_base_unit::unit_type(), "(1\\.#INF|inf|INF|Inf) meter");
+ BOOST_UNITS_TEST_OUTPUT_REGEX(-std::numeric_limits<float>::infinity()*meter_base_unit::unit_type(), "-(1\\.#INF|inf|INF|Inf) meter");
+ BOOST_UNITS_TEST_OUTPUT_REGEX(std::numeric_limits<double>::quiet_NaN()*meter_base_unit::unit_type(), "(1\\.#QNAN|nan|NaNQ|NaN) meter");
+ BOOST_UNITS_TEST_OUTPUT_REGEX(-std::numeric_limits<double>::quiet_NaN()*meter_base_unit::unit_type(), "-?(1\\.#IND|nan|nan\\(ind\\)|NaNQ|NaN) meter");
+
+ BOOST_UNITS_TEST_OUTPUT(1.5*velocity(), "1.5 meter second^-1");
+ BOOST_UNITS_TEST_OUTPUT(1.5*scaled_length(), "1.5 kilometer");
+ BOOST_UNITS_TEST_OUTPUT(1.5*scaled_velocity1(), "1.5 kilo(meter second^-1)");
+ BOOST_UNITS_TEST_OUTPUT(1.5*millisecond_base_unit::unit_type(), "1.5 millisecond");
+ BOOST_UNITS_TEST_OUTPUT(1.5*scaled_time(), "1.5 millisecond");
+ BOOST_UNITS_TEST_OUTPUT(1.5*scaled_velocity2(), "1.5 meter millisecond^-1");
+ BOOST_UNITS_TEST_OUTPUT(1.5*area(), "1.5 meter^2");
+ BOOST_UNITS_TEST_OUTPUT(1.5*scaled_area(), "1.5 kilo(meter^2)");
+ BOOST_UNITS_TEST_OUTPUT(1.5*double_scaled_length(), "1.536 megameter"); // 1.5 * 2^10 = 1.5 * 1024 = 1.536
+ BOOST_UNITS_TEST_OUTPUT(1.5*double_scaled_length2(), "1.5 kiloscaled_meter");
+ BOOST_UNITS_TEST_OUTPUT(1.5*custom1(), "1.5 custom1");
+ BOOST_UNITS_TEST_OUTPUT(1.5*custom2(), "1.5 custom2");
+ BOOST_UNITS_TEST_OUTPUT(1.5*scaled_custom1(), "1.5 kilocustom1");
+ BOOST_UNITS_TEST_OUTPUT(1.5*scaled_custom2(), "1.5 kilocustom2");
+ BOOST_UNITS_TEST_OUTPUT(1.5*boost::units::absolute<meter_base_unit::unit_type>(), "1.5 absolute meter");
+ BOOST_UNITS_TEST_OUTPUT(std::pow(2., 10) * byte_base_unit::unit_type(), "1.024 kilobyte");
+
+ BOOST_UNITS_TEST_OUTPUT(1.5, "1.5"); // scalar.
+ BOOST_UNITS_TEST_OUTPUT(1567., "1567"); // scalars are *not* autoprefixed.
+ BOOST_UNITS_TEST_OUTPUT(0.00015, "0.00015"); // scalars are *not* autoprefixed.
+ BOOST_UNITS_TEST_OUTPUT(-1.5, "-1.5"); // scalar.
+ BOOST_UNITS_TEST_OUTPUT(-1567., "-1567"); // scalars are *not* autoprefixed.
+ BOOST_UNITS_TEST_OUTPUT(-0.00015, "-0.00015"); // scalars are *not* autoprefixed.
+#undef FORMATTERS
+}
+
+BOOST_AUTO_TEST_CASE(test_output_autoprefixed_quantity_symbol)
+{ // Engineering autoprefix, with symbol format.
+#define FORMATTERS << boost::units::symbol_format << boost::units::engineering_prefix
+ // Single base unit like m.
+ BOOST_UNITS_TEST_OUTPUT(1.5*meter_base_unit::unit_type(), "1.5 m");
+ BOOST_UNITS_TEST_OUTPUT(1500.0*meter_base_unit::unit_type(), "1.5 km");
+ BOOST_UNITS_TEST_OUTPUT(1.5e7*meter_base_unit::unit_type(), "15 Mm");
+ BOOST_UNITS_TEST_OUTPUT(1.5e-3*meter_base_unit::unit_type(), "1.5 mm");
+ BOOST_UNITS_TEST_OUTPUT(1.5e-9*meter_base_unit::unit_type(), "1.5 nm");
+ BOOST_UNITS_TEST_OUTPUT(1.5e-8*meter_base_unit::unit_type(), "15 nm");
+ BOOST_UNITS_TEST_OUTPUT(1.5e-10*meter_base_unit::unit_type(), "150 pm");
+ // Too small or large for a multiple name.
+ BOOST_UNITS_TEST_OUTPUT_REGEX(9.99999e-25 * meter_base_unit::unit_type(), "9\\.99999e-0?25 m"); // Just too small for multiple.
+ BOOST_UNITS_TEST_OUTPUT_REGEX(1e+28 * meter_base_unit::unit_type(), "1e\\+0?28 m"); // Just too large for multiple.
+ BOOST_UNITS_TEST_OUTPUT_REGEX(1.5e-25 * meter_base_unit::unit_type(), "1\\.5e-0?25 m"); // Too small for multiple.
+ BOOST_UNITS_TEST_OUTPUT_REGEX(1.5e+28 * meter_base_unit::unit_type(), "1\\.5e\\+0?28 m"); // Too large for multiple.
+ //
+ BOOST_UNITS_TEST_OUTPUT_REGEX((std::numeric_limits<float>::max)()*meter_base_unit::unit_type(), "3\\.40282e\\+0?38 m");
+ BOOST_UNITS_TEST_OUTPUT_REGEX((std::numeric_limits<float>::min)()*meter_base_unit::unit_type(), "1\\.17549e-0?38 m");
+ BOOST_UNITS_TEST_OUTPUT((std::numeric_limits<double>::max)()*meter_base_unit::unit_type(), "1.79769e+308 m");
+ BOOST_UNITS_TEST_OUTPUT((std::numeric_limits<double>::min)()*meter_base_unit::unit_type(), "2.22507e-308 m");
+
+ BOOST_UNITS_TEST_OUTPUT(1.5*velocity(), "1.5 m s^-1");
+ BOOST_UNITS_TEST_OUTPUT(1.5*scaled_length(), "1.5 km");
+ BOOST_UNITS_TEST_OUTPUT(1.5*scaled_velocity1(), "1.5 k(m s^-1)");
+ BOOST_UNITS_TEST_OUTPUT(1.5*millisecond_base_unit::unit_type(), "1.5 ms");
+ BOOST_UNITS_TEST_OUTPUT(1.5*scaled_time(), "1.5 ms");
+ BOOST_UNITS_TEST_OUTPUT(1.5*scaled_velocity2(), "1.5 m ms^-1");
+ BOOST_UNITS_TEST_OUTPUT(1.5*area(), "1.5 m^2");
+ BOOST_UNITS_TEST_OUTPUT(1.5*scaled_area(), "1.5 k(m^2)");
+ BOOST_UNITS_TEST_OUTPUT(1.5*double_scaled_length(), "1.536 Mm"); // 1.5 * 2^10 = 1.5 * 1024 = 1.536
+ BOOST_UNITS_TEST_OUTPUT(1.5*double_scaled_length2(), "1.5 kscm");
+ BOOST_UNITS_TEST_OUTPUT(1.5*custom1(), "1.5 c1");
+ BOOST_UNITS_TEST_OUTPUT(1.5*custom2(), "1.5 c2");
+ BOOST_UNITS_TEST_OUTPUT(1.5*scaled_custom1(), "1.5 kc1");
+ BOOST_UNITS_TEST_OUTPUT(1.5*scaled_custom2(), "1.5 kc2");
+ BOOST_UNITS_TEST_OUTPUT(1.5*boost::units::absolute<meter_base_unit::unit_type>(), "1.5 absolute m");
+ BOOST_UNITS_TEST_OUTPUT(std::pow(2., 10) * byte_base_unit::unit_type(), "1.024 kb");
+
+#undef FORMATTERS
+}
+
+BOOST_AUTO_TEST_CASE(test_output_auto_binary_prefixed_quantity_symbol)
+{ // Binary prefix with symbol format.
+#define FORMATTERS << boost::units::symbol_format << boost::units::binary_prefix
+ BOOST_UNITS_TEST_OUTPUT(1024 * byte_base_unit::unit_type(), "1 Kib");
+ BOOST_UNITS_TEST_OUTPUT(std::pow(2., 20) * byte_base_unit::unit_type(), "1 Mib");
+ BOOST_UNITS_TEST_OUTPUT(std::pow(2., 30) * byte_base_unit::unit_type(), "1 Gib");
+ BOOST_UNITS_TEST_OUTPUT(std::pow(2., 40) * byte_base_unit::unit_type(), "1 Tib");
+ BOOST_UNITS_TEST_OUTPUT(std::pow(2., 50) * byte_base_unit::unit_type(), "1 Pib");
+ BOOST_UNITS_TEST_OUTPUT(std::pow(2., 60) * byte_base_unit::unit_type(), "1 Eib");
+ BOOST_UNITS_TEST_OUTPUT(std::pow(2., 70) * byte_base_unit::unit_type(), "1 Zib");
+ BOOST_UNITS_TEST_OUTPUT(std::pow(2., 80) * byte_base_unit::unit_type(), "1 Yib");
+ BOOST_UNITS_TEST_OUTPUT(42, "42"); // integer scalar.
+ BOOST_UNITS_TEST_OUTPUT(-42, "-42"); // integer scalar.
+ BOOST_UNITS_TEST_OUTPUT(1567, "1567"); // scalars are *not* autoprefixed.
+ BOOST_UNITS_TEST_OUTPUT(-1567, "-1567"); // scalars are *not* autoprefixed.
+#undef FORMATTERS
+}
+
+BOOST_AUTO_TEST_CASE(test_output_auto_binary_prefixed_quantity_name)
+{ // Binary prefix with name format.
+ // http://physics.nist.gov/cuu/Units/binary.html
+ // 1998 the International Electrotechnical Commission (IEC) approved
+ // IEC 60027-2, Second edition, 2000-11, Letter symbols to be used in electrical technology
+ // - Part 2: Telecommunications and electronics.
+ // IEC 80000-13:2008, Quantities and units
+ // - Part 13: Information science and technology
+#define FORMATTERS << boost::units::name_format << boost::units::binary_prefix
+ BOOST_UNITS_TEST_OUTPUT(2048 * byte_base_unit::unit_type(), "2 kibibyte");
+ BOOST_UNITS_TEST_OUTPUT(std::pow(2., 32) *byte_base_unit::unit_type(), "4 gibibyte");
+ BOOST_UNITS_TEST_OUTPUT(std::pow(2., 41) *byte_base_unit::unit_type(), "2 tebibyte"); // http://en.wikipedia.org/wiki/Tebibyte
+ BOOST_UNITS_TEST_OUTPUT(std::pow(2., 50) *byte_base_unit::unit_type(), "1 pebibyte");
+ BOOST_UNITS_TEST_OUTPUT(std::pow(2., 60) *byte_base_unit::unit_type(), "1 exbibyte");
+ BOOST_UNITS_TEST_OUTPUT(std::pow(2., 70) *byte_base_unit::unit_type(), "1 zebibyte");
+ BOOST_UNITS_TEST_OUTPUT(std::pow(2., 80) *byte_base_unit::unit_type(), "1 yobibyte");
+ BOOST_UNITS_TEST_OUTPUT(2048, "2048"); // scalars are *not* autoprefixed.
+ BOOST_UNITS_TEST_OUTPUT(-4096, "-4096"); // scalars are *not* autoprefixed.
+#undef FORMATTERS
+}
+
+// Tests on using more than one format or prefix - only the last specified should be used.
+// (This may indicate a programming mistake, but it is ignored).
+BOOST_AUTO_TEST_CASE(test_output_quantity_name_duplicate)
+{ // Ensure that if more than one format specified, only the last is used.
+#define FORMATTERS << boost::units::symbol_format << boost::units::name_format
+ BOOST_UNITS_TEST_OUTPUT(1.5*meter_base_unit::unit_type(), "1.5 meter");
+#undef FORMATTERS
+}
+
+BOOST_AUTO_TEST_CASE(test_output_quantity_symbol_duplicate)
+{ // Ensure that if more than one format specified, only the last is used.
+#define FORMATTERS << boost::units::name_format << boost::units::symbol_format
+ BOOST_UNITS_TEST_OUTPUT(1.5*meter_base_unit::unit_type(), "1.5 m");
+#undef FORMATTERS
+}
+
+BOOST_AUTO_TEST_CASE(test_output_auto_binary_prefixed_quantity_name_duplicate)
+{ // Ensure that if more than one auto prefix specified, only the last is used.
+#define FORMATTERS << boost::units::name_format << boost::units::binary_prefix << boost::units::engineering_prefix
+ BOOST_UNITS_TEST_OUTPUT(2048 * byte_base_unit::unit_type(), "2.048 kilobyte");
+#undef FORMATTERS
+}
+
+BOOST_AUTO_TEST_CASE(test_output_auto_binary_prefixed_quantity_symbol_duplicate)
+{ // Ensure that if more than one auto prefix specified, only the last is used.
+#define FORMATTERS << boost::units::symbol_format << boost::units::engineering_prefix << boost::units::binary_prefix
+ BOOST_UNITS_TEST_OUTPUT(2048 * byte_base_unit::unit_type(), "2 Kib");
+#undef FORMATTERS
+}
+
+BOOST_AUTO_TEST_CASE(test_output_typename_format)
+{ // Displays typename formatting result. The test doesn't check the formatting result
+ // and thus doesn't fail because the formatting result is platform-dependent.
+#define FORMATTERS << boost::units::typename_format
+ BOOST_UNITS_TEST_OUTPUT_DISPLAY(meter_base_unit::unit_type());
+ BOOST_UNITS_TEST_OUTPUT_DISPLAY(velocity());
+ BOOST_UNITS_TEST_OUTPUT_DISPLAY(scaled_length());
+ BOOST_UNITS_TEST_OUTPUT_DISPLAY(scaled_velocity1());
+ BOOST_UNITS_TEST_OUTPUT_DISPLAY(millisecond_base_unit::unit_type());
+ BOOST_UNITS_TEST_OUTPUT_DISPLAY(scaled_time());
+ BOOST_UNITS_TEST_OUTPUT_DISPLAY(scaled_velocity2());
+ BOOST_UNITS_TEST_OUTPUT_DISPLAY(area());
+ BOOST_UNITS_TEST_OUTPUT_DISPLAY(scaled_area());
+ BOOST_UNITS_TEST_OUTPUT_DISPLAY(double_scaled_length());
+ BOOST_UNITS_TEST_OUTPUT_DISPLAY(double_scaled_length2());
+ BOOST_UNITS_TEST_OUTPUT_DISPLAY(custom1());
+ BOOST_UNITS_TEST_OUTPUT_DISPLAY(custom2());
+ BOOST_UNITS_TEST_OUTPUT_DISPLAY(scaled_custom1());
+ BOOST_UNITS_TEST_OUTPUT_DISPLAY(scaled_custom2());
+ BOOST_UNITS_TEST_OUTPUT_DISPLAY(boost::units::absolute<meter_base_unit::unit_type>());
+#undef FORMATTERS
+}
diff --git a/src/boost/libs/units/test/test_predicates.cpp b/src/boost/libs/units/test/test_predicates.cpp
new file mode 100644
index 000000000..d05c4eafb
--- /dev/null
+++ b/src/boost/libs/units/test/test_predicates.cpp
@@ -0,0 +1,100 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2008 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)
+
+/**
+\file
+
+\brief test_predicates.cpp
+
+\details
+Test metafunctions is_unit, is_quantity, is_dimension_list ....
+
+Output:
+@verbatim
+@endverbatim
+**/
+
+#include <boost/mpl/assert.hpp>
+#include <boost/mpl/list/list0.hpp>
+
+#include <boost/units/base_dimension.hpp>
+#include <boost/units/base_unit.hpp>
+#include <boost/units/dimension.hpp>
+#include <boost/units/is_dimension_list.hpp>
+#include <boost/units/is_quantity.hpp>
+#include <boost/units/is_quantity_of_dimension.hpp>
+#include <boost/units/is_quantity_of_system.hpp>
+#include <boost/units/is_unit.hpp>
+#include <boost/units/is_unit_of_dimension.hpp>
+#include <boost/units/is_unit_of_system.hpp>
+#include <boost/units/make_system.hpp>
+#include <boost/units/quantity.hpp>
+#include <boost/units/unit.hpp>
+
+namespace bu = boost::units;
+
+struct dimension_tag : boost::units::base_dimension<dimension_tag,0> { };
+
+typedef dimension_tag::dimension_type dimension;
+
+struct base_unit1 : bu::base_unit<base_unit1, dimension, 100> {};
+struct base_unit2 : bu::base_unit<base_unit2, dimension, 101> {};
+
+typedef bu::make_system<base_unit1>::type system1;
+typedef bu::make_system<base_unit2>::type system2;
+
+int main(int,char *[])
+{
+ BOOST_MPL_ASSERT((bu::is_dimension_list<bu::dimensionless_type>));
+ BOOST_MPL_ASSERT((bu::is_dimension_list<dimension>));
+ BOOST_MPL_ASSERT_NOT((bu::is_dimension_list<boost::mpl::list0<> >));
+ BOOST_MPL_ASSERT_NOT((bu::is_dimension_list<int>));
+
+ BOOST_MPL_ASSERT((bu::is_unit<bu::unit<bu::dimensionless_type, system1> >));
+ BOOST_MPL_ASSERT((bu::is_unit<bu::unit<dimension, system1> >));
+ BOOST_MPL_ASSERT_NOT((bu::is_unit<int>));
+
+ BOOST_MPL_ASSERT((bu::is_unit_of_system<bu::unit<bu::dimensionless_type, system1>, system1>));
+ BOOST_MPL_ASSERT((bu::is_unit_of_system<bu::unit<dimension, system1>, system1>));
+ BOOST_MPL_ASSERT_NOT((bu::is_unit_of_system<bu::unit<bu::dimensionless_type, system1>, system2>));
+ BOOST_MPL_ASSERT_NOT((bu::is_unit_of_system<bu::unit<dimension, system1>, system2>));
+ BOOST_MPL_ASSERT_NOT((bu::is_unit_of_system<int, system1>));
+ BOOST_MPL_ASSERT_NOT((bu::is_unit_of_system<int, system2>));
+
+ BOOST_MPL_ASSERT((bu::is_unit_of_dimension<bu::unit<bu::dimensionless_type, system1>, bu::dimensionless_type>));
+ BOOST_MPL_ASSERT((bu::is_unit_of_dimension<bu::unit<dimension, system1>, dimension>));
+ BOOST_MPL_ASSERT_NOT((bu::is_unit_of_dimension<bu::unit<bu::dimensionless_type, system1>, dimension>));
+ BOOST_MPL_ASSERT_NOT((bu::is_unit_of_dimension<bu::unit<dimension, system1>, bu::dimensionless_type>));
+ BOOST_MPL_ASSERT_NOT((bu::is_unit_of_dimension<int, bu::dimensionless_type>));
+ BOOST_MPL_ASSERT_NOT((bu::is_unit_of_dimension<int, dimension>));
+
+ BOOST_MPL_ASSERT((bu::is_quantity<bu::quantity<bu::unit<bu::dimensionless_type, system1> > >));
+ BOOST_MPL_ASSERT((bu::is_quantity<bu::quantity<bu::unit<dimension, system1> > >));
+ BOOST_MPL_ASSERT_NOT((bu::is_quantity<int>));
+
+ BOOST_MPL_ASSERT((bu::is_quantity<bu::quantity<bu::unit<bu::dimensionless_type, system1>, int> >));
+ BOOST_MPL_ASSERT((bu::is_quantity<bu::quantity<bu::unit<dimension, system1>, int> >));
+
+ BOOST_MPL_ASSERT((bu::is_quantity_of_system<bu::quantity<bu::unit<bu::dimensionless_type, system1> >, system1>));
+ BOOST_MPL_ASSERT((bu::is_quantity_of_system<bu::quantity<bu::unit<dimension, system1> >, system1>));
+ BOOST_MPL_ASSERT_NOT((bu::is_quantity_of_system<bu::quantity<bu::unit<bu::dimensionless_type, system1> >, system2>));
+ BOOST_MPL_ASSERT_NOT((bu::is_quantity_of_system<bu::quantity<bu::unit<dimension, system1> >, system2>));
+ BOOST_MPL_ASSERT_NOT((bu::is_quantity_of_system<int, system1>));
+ BOOST_MPL_ASSERT_NOT((bu::is_quantity_of_system<int, system2>));
+
+ BOOST_MPL_ASSERT((bu::is_quantity_of_dimension<bu::quantity<bu::unit<bu::dimensionless_type, system1> >, bu::dimensionless_type>));
+ BOOST_MPL_ASSERT((bu::is_quantity_of_dimension<bu::quantity<bu::unit<dimension, system1> >, dimension>));
+ BOOST_MPL_ASSERT_NOT((bu::is_quantity_of_dimension<bu::quantity<bu::unit<bu::dimensionless_type, system1> >, dimension>));
+ BOOST_MPL_ASSERT_NOT((bu::is_quantity_of_dimension<bu::quantity<bu::unit<dimension, system1> >, bu::dimensionless_type>));
+ BOOST_MPL_ASSERT_NOT((bu::is_quantity_of_dimension<int, bu::dimensionless_type>));
+ BOOST_MPL_ASSERT_NOT((bu::is_quantity_of_dimension<int, dimension>));
+
+ return 0;
+}
diff --git a/src/boost/libs/units/test/test_quantity.cpp b/src/boost/libs/units/test/test_quantity.cpp
new file mode 100644
index 000000000..b6461bf26
--- /dev/null
+++ b/src/boost/libs/units/test/test_quantity.cpp
@@ -0,0 +1,203 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2008 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)
+
+/**
+\file
+
+\brief test_units_1.cpp
+
+\details
+Test unit class.
+
+Output:
+@verbatim
+@endverbatim
+**/
+
+#include "test_header.hpp"
+
+#include <boost/units/pow.hpp>
+
+namespace bu = boost::units;
+
+BOOST_STATIC_CONSTEXPR double E_ = 2.718281828459045235360287471352662497757;
+
+int test_main(int,char *[])
+{
+ // default constructor
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<bu::energy> E1;
+ BOOST_CHECK(E1.value() == double());
+
+ // value_type constructor
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<bu::energy> E2(E_*bu::joules);
+ BOOST_CHECK(E2.value() == E_);
+
+ // copy constructor
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<bu::energy> E3(E2);
+ BOOST_CHECK(E3.value() == E_);
+
+ // operator=
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<bu::energy> E4 = E2;
+ BOOST_CHECK(E4.value() == E_);
+
+ // implicit copy constructor value_type conversion
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<bu::energy,float> E5(E2);
+ BOOST_UNITS_CHECK_CLOSE(E5.value(),float(E_));
+
+ // implicit operator= value_type conversion
+ //BOOST_CONSTEXPR_OR_CONST bu::quantity<bu::energy,float> E7 = E2;
+ //BOOST_UNITS_CHECK_CLOSE(E7.value(),float(E_));
+
+ //BOOST_CONSTEXPR_OR_CONST bu::quantity<bu::energy,long> E8 = E2;
+ //BOOST_CHECK(E8.value() == long(E_));
+
+ // const construction
+ bu::quantity<bu::energy> E9(E2);
+ BOOST_CHECK(E9.value() == E_);
+
+ // value assignment
+ bu::quantity_cast<double&>(E9) = 1.5;
+ BOOST_CHECK(E9.value() == 1.5);
+
+ // value assignment with implicit value_type conversion
+ bu::quantity_cast<double&>(E9) = 2;
+ BOOST_CHECK(E9.value() == double(2));
+
+ // operator+=(this_type)
+ E9 = 2.0*bu::joules;
+ E9 += E9;
+ BOOST_CHECK(E9.value() == 4.0);
+
+ // operator-=(this_type)
+ E9 = 2.0*bu::joules;
+ E9 -= E9;
+ BOOST_CHECK(E9.value() == 0.0);
+
+ // operator*=(value_type)
+ E9 = 2.0*bu::joules;
+ E9 *= 2.0;
+ BOOST_CHECK(E9.value() == 4.0);
+
+ // operator/=(value_type)
+ E9 = 2.0*bu::joules;
+ E9 /= 2.0;
+ BOOST_CHECK(E9.value() == 1.0);
+
+ // static construct quantity from value_type
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<bu::energy> E(bu::quantity<bu::energy>::from_value(2.5));
+ BOOST_CHECK(E.value() == 2.5);
+
+ // quantity_cast
+
+ // unit * scalar
+ BOOST_CHECK(bu::joules*2.0 == bu::quantity<bu::energy>::from_value(2.0));
+
+ // unit / scalar
+ BOOST_CHECK(bu::joules/2.0 == bu::quantity<bu::energy>::from_value(0.5));
+
+ // scalar * unit
+ BOOST_CHECK(2.0*bu::joules == bu::quantity<bu::energy>::from_value(2.0));
+
+ // scalar / unit
+ BOOST_CHECK(2.0/bu::joules == bu::quantity<bu::inverse_energy>::from_value(2.0));
+
+ // quantity * scalar
+ BOOST_CHECK(E*2.0 == bu::quantity<bu::energy>::from_value(5.0));
+
+ // quantity / scalar
+ BOOST_CHECK(E/2.0 == bu::quantity<bu::energy>::from_value(1.25));
+
+ // scalar * quantity
+ BOOST_CHECK(2.0*E == bu::quantity<bu::energy>::from_value(5.0));
+
+ // scalar / quantity
+ BOOST_CHECK(2.0/E == bu::quantity<bu::inverse_energy>::from_value(0.8));
+
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<bu::length> L(1.0*bu::meters);
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<bu::mass> M(2.0*bu::kilograms);
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<bu::time> T(3.0*bu::seconds);
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<bu::velocity> V(bu::quantity<bu::velocity>::from_value(4.0));
+
+ // unit * quantity
+ BOOST_CHECK(bu::seconds*V == 4.0*bu::meters);
+
+ // unit / quantity
+ BOOST_CHECK(bu::meters/V == 0.25*bu::seconds);
+
+ // quantity * unit
+ BOOST_CHECK(V*bu::seconds == 4.0*bu::meters);
+
+ // quantity / unit
+ BOOST_CHECK(V/bu::meters == 4.0/bu::seconds);
+
+ // +quantity
+ BOOST_CHECK(+V == 4.0*bu::meters_per_second);
+
+ // -quantity
+ BOOST_CHECK(-V == -4.0*bu::meters_per_second);
+
+ // quantity + quantity
+ BOOST_CHECK(V+V == 8.0*bu::meters_per_second);
+
+ // quantity - quantity
+ BOOST_CHECK(V-V == 0.0*bu::meters_per_second);
+
+ // quantity * quantity
+ BOOST_CHECK(V*T == 12.0*bu::meters);
+
+ // quantity / quantity
+ BOOST_CHECK(L/V == 0.25*bu::seconds);
+
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<bu::area> A(2.0*bu::square_meters);
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<bu::volume> VL(1.0*bu::cubic_meters);
+
+ // integer power of quantity
+ BOOST_CHECK(2.0*bu::pow<2>(L) == A);
+
+ // rational power of quantity
+ BOOST_CHECK((bu::pow< bu::static_rational<2,3> >(VL) == 0.5*A));
+
+ // integer root of quantity
+ BOOST_CHECK(bu::root<2>(A) == std::sqrt(2.0)*L);
+
+ // rational root of quantity
+ BOOST_CHECK((bu::root< bu::static_rational<3,2> >(VL) == 0.5*A));
+
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<bu::area> A1(0.0*bu::square_meters),
+ A2(0.0*bu::square_meters),
+ A3(1.0*bu::square_meters),
+ A4(-1.0*bu::square_meters);
+
+ // operator==
+ BOOST_CHECK((A1 == A2) == true);
+ BOOST_CHECK((A1 == A3) == false);
+
+ // operator!=
+ BOOST_CHECK((A1 != A2) == false);
+ BOOST_CHECK((A1 != A3) == true);
+
+ // operator<
+ BOOST_CHECK((A1 < A2) == false);
+ BOOST_CHECK((A1 < A3) == true);
+
+ // operator<=
+ BOOST_CHECK((A1 <= A2) == true);
+ BOOST_CHECK((A1 <= A3) == true);
+
+ // operator>
+ BOOST_CHECK((A1 > A2) == false);
+ BOOST_CHECK((A1 > A4) == true);
+
+ // operator>=
+ BOOST_CHECK((A1 >= A2) == true);
+ BOOST_CHECK((A1 >= A4) == true);
+
+ return 0;
+}
diff --git a/src/boost/libs/units/test/test_reduce_unit.cpp b/src/boost/libs/units/test/test_reduce_unit.cpp
new file mode 100644
index 000000000..c9daed091
--- /dev/null
+++ b/src/boost/libs/units/test/test_reduce_unit.cpp
@@ -0,0 +1,30 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2007-2008 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)
+
+/**
+\file
+
+\brief test_reduce_unit.cpp
+
+\details
+Test that reduce_unit works correctly by itself to try to isolate problems.
+
+Output:
+@verbatim
+@endverbatim
+**/
+
+#include <boost/units/reduce_unit.hpp>
+#include <boost/units/base_units/si/kelvin.hpp>
+
+#include <boost/mpl/assert.hpp>
+#include <boost/type_traits/is_same.hpp>
+
+BOOST_MPL_ASSERT((boost::is_same<boost::units::reduce_unit<boost::units::si::kelvin_base_unit::unit_type>::type, boost::units::si::kelvin_base_unit::unit_type>));
diff --git a/src/boost/libs/units/test/test_scaled_conversion.cpp b/src/boost/libs/units/test/test_scaled_conversion.cpp
new file mode 100644
index 000000000..c9da8fcf3
--- /dev/null
+++ b/src/boost/libs/units/test/test_scaled_conversion.cpp
@@ -0,0 +1,66 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2007-2008 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)
+
+/**
+\file
+
+\brief test_scaled_conversion.cpp
+
+\details
+Test unit scaling
+
+Output:
+@verbatim
+@endverbatim
+**/
+
+#include <boost/units/quantity.hpp>
+#include <boost/units/conversion.hpp>
+#include <boost/units/unit.hpp>
+#include <boost/units/base_unit.hpp>
+#include <boost/units/scaled_base_unit.hpp>
+#include <boost/units/scale.hpp>
+#include <boost/units/base_dimension.hpp>
+#include <boost/units/derived_dimension.hpp>
+
+#include <boost/test/minimal.hpp>
+
+#define BOOST_UNITS_CHECK_CLOSE(a, b) (BOOST_CHECK((std::abs((a) - (b)) < .0000001)))
+
+namespace bu = boost::units;
+
+struct base_dimension1 : bu::base_dimension<base_dimension1, 1> {};
+struct base_dimension2 : bu::base_dimension<base_dimension2, 2> {};
+struct base_dimension3 : bu::base_dimension<base_dimension3, 3> {};
+
+typedef bu::derived_dimension<base_dimension1, 1, base_dimension2, 1, base_dimension3, 1>::type dimension4;
+
+struct base_unit1 : bu::base_unit<base_unit1, base_dimension1::dimension_type, 1> {};
+struct base_unit2 : bu::base_unit<base_unit2, base_dimension1::dimension_type, 2> {};
+struct base_unit3 : bu::base_unit<base_unit3, base_dimension1::dimension_type, 3> {};
+struct base_unit4 : bu::base_unit<base_unit4, dimension4, 4> {};
+struct base_unit5 : bu::base_unit<base_unit5, base_dimension3::dimension_type, 5> {};
+
+typedef bu::scaled_base_unit<base_unit2, bu::scale<10, bu::static_rational<3> > > scaled_base_unit2;
+typedef bu::scaled_base_unit<base_unit4, bu::scale<10, bu::static_rational<3> > > scaled_base_unit4;
+
+BOOST_UNITS_DEFINE_CONVERSION_FACTOR(base_unit1, scaled_base_unit2, double, 5);
+BOOST_UNITS_DEFINE_CONVERSION_FACTOR(scaled_base_unit2, base_unit3, double, 3);
+
+int test_main(int,char *[])
+{
+ BOOST_UNITS_CHECK_CLOSE(bu::conversion_factor(base_unit1::unit_type(), base_unit2::unit_type()), 5000);
+ BOOST_UNITS_CHECK_CLOSE(bu::conversion_factor(base_unit2::unit_type(), base_unit3::unit_type()), 0.003);
+ BOOST_UNITS_CHECK_CLOSE(bu::conversion_factor(scaled_base_unit2::unit_type(), base_unit2::unit_type()), 1000);
+
+ BOOST_UNITS_CHECK_CLOSE(bu::conversion_factor(base_unit4::unit_type()/base_unit5::unit_type(), scaled_base_unit4::unit_type()/base_unit5::unit_type()), 1e-3);
+
+ return(0);
+}
diff --git a/src/boost/libs/units/test/test_scaled_unit.cpp b/src/boost/libs/units/test/test_scaled_unit.cpp
new file mode 100644
index 000000000..2357a98dc
--- /dev/null
+++ b/src/boost/libs/units/test/test_scaled_unit.cpp
@@ -0,0 +1,76 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2007-2008 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)
+
+/**
+\file
+
+\brief test_scaled_conversion.cpp
+
+\details
+Test unit scaling
+
+Output:
+@verbatim
+@endverbatim
+**/
+
+#define BOOST_TEST_MAIN
+
+#include <boost/units/systems/si/prefixes.hpp>
+#include <boost/units/systems/si/time.hpp>
+#include <boost/units/quantity.hpp>
+#include <boost/units/io.hpp>
+
+#include <sstream>
+
+#include <boost/test/unit_test.hpp>
+#include <boost/test/floating_point_comparison.hpp>
+
+namespace bu = boost::units;
+namespace si = boost::units::si;
+
+BOOST_AUTO_TEST_CASE(test_scaled_to_plain) {
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<si::time> s1 = 12.5 * si::seconds;
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<si::time> s2(si::nano * s1);
+ BOOST_CHECK_CLOSE_FRACTION(1e-9 * s1.value(), s2.value(), 0.000000001);
+}
+
+BOOST_AUTO_TEST_CASE(test_plain_to_scaled) {
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<si::time> s1 = 12.5 * si::seconds;
+ typedef bu::multiply_typeof_helper<si::nano_type, si::time>::type time_unit;
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<time_unit> s2(s1);
+ BOOST_CHECK_CLOSE_FRACTION(1e9 * s1.value(), s2.value(), 0.000000001);
+}
+
+BOOST_AUTO_TEST_CASE(test_scaled_to_scaled) {
+ typedef bu::multiply_typeof_helper<si::mega_type, si::time>::type mega_time_unit;
+ typedef bu::multiply_typeof_helper<si::micro_type, si::time>::type micro_time_unit;
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<mega_time_unit> s1(12.5 * si::seconds);
+ BOOST_CONSTEXPR_OR_CONST bu::quantity<micro_time_unit> s2(s1);
+ BOOST_CHECK_CLOSE_FRACTION(1e12 * s1.value(), s2.value(), 0.000000001);
+}
+
+BOOST_AUTO_TEST_CASE(test_conversion_factor) {
+ BOOST_CHECK_CLOSE_FRACTION(conversion_factor(si::nano*si::seconds, si::seconds), 1e-9, 0.000000001);
+ BOOST_CHECK_CLOSE_FRACTION(conversion_factor(si::seconds, si::nano*si::seconds), 1e9, 0.000000001);
+ BOOST_CHECK_CLOSE_FRACTION(conversion_factor(si::mega*si::seconds, si::micro*si::seconds), 1e12, 0.000000001);
+}
+
+BOOST_AUTO_TEST_CASE(test_output) {
+ std::stringstream stream;
+ stream << si::nano * 12.5 * si::seconds;
+ BOOST_CHECK_EQUAL(stream.str(), "12.5 ns");
+}
+
+BOOST_AUTO_TEST_CASE(test_output_name) {
+ std::stringstream stream;
+ stream << bu::name_format << si::nano * 12.5 * si::seconds;
+ BOOST_CHECK_EQUAL(stream.str(), "12.5 nanosecond");
+}
diff --git a/src/boost/libs/units/test/test_sqrt_scaled_unit.cpp b/src/boost/libs/units/test/test_sqrt_scaled_unit.cpp
new file mode 100644
index 000000000..8224fa254
--- /dev/null
+++ b/src/boost/libs/units/test/test_sqrt_scaled_unit.cpp
@@ -0,0 +1,48 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2008 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)
+
+/**
+\file
+
+\brief test_units_1.cpp
+
+\details
+Test unit class.
+
+Output:
+@verbatim
+@endverbatim
+**/
+
+#include "test_header.hpp"
+
+#include <boost/units/cmath.hpp>
+#include <boost/units/scale.hpp>
+#include <boost/units/make_scaled_unit.hpp>
+
+namespace bu = boost::units;
+
+static const double E_ = 2.718281828459045235360287471352662497757;
+
+typedef bu::make_scaled_unit<bu::length,
+ bu::scale<10, bu::static_rational<-3> > >::type milli_meter_unit;
+
+typedef bu::make_scaled_unit<bu::area,
+ bu::scale<10, bu::static_rational<-6> > >::type micro_meter2_unit;
+
+int test_main(int,char *[])
+{
+ const bu::quantity<micro_meter2_unit> E1 = E_*micro_meter2_unit();
+ const bu::quantity<milli_meter_unit> E2 = sqrt(E1);
+
+ BOOST_CHECK(E1.value() == E_);
+ BOOST_CHECK(E2.value() == sqrt(E_));
+ return 0;
+}
diff --git a/src/boost/libs/units/test/test_trig.cpp b/src/boost/libs/units/test/test_trig.cpp
new file mode 100644
index 000000000..574c460a5
--- /dev/null
+++ b/src/boost/libs/units/test/test_trig.cpp
@@ -0,0 +1,79 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2009 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)
+
+/**
+\file
+
+\brief test_trig.cpp
+
+\details
+Test trigonometric functions.
+
+Output:
+@verbatim
+@endverbatim
+**/
+
+#include <cmath>
+#include <boost/units/cmath.hpp>
+#include <boost/units/io.hpp>
+#include <boost/units/systems/si/plane_angle.hpp>
+#include <boost/units/systems/si/length.hpp>
+#include <boost/units/systems/si/dimensionless.hpp>
+#include <boost/units/systems/angle/degrees.hpp>
+
+#define BOOST_TEST_MAIN
+#include <boost/test/unit_test.hpp>
+
+using boost::units::si::radians;
+using boost::units::si::si_dimensionless;
+using boost::units::degree::degrees;
+BOOST_UNITS_STATIC_CONSTANT(degree_dimensionless, boost::units::degree::dimensionless);
+using boost::units::si::meters;
+BOOST_UNITS_STATIC_CONSTANT(heterogeneous_dimensionless, boost::units::reduce_unit<boost::units::si::dimensionless>::type);
+
+BOOST_AUTO_TEST_CASE(test_sin) {
+ BOOST_CHECK_EQUAL(boost::units::sin(2.0 * radians), std::sin(2.0) * si_dimensionless);
+ BOOST_CHECK_CLOSE_FRACTION(static_cast<double>(boost::units::sin(15.0 * degrees)), 0.2588, 0.0004);
+}
+
+BOOST_AUTO_TEST_CASE(test_cos) {
+ BOOST_CHECK_EQUAL(boost::units::cos(2.0 * radians), std::cos(2.0) * si_dimensionless);
+ BOOST_CHECK_CLOSE_FRACTION(static_cast<double>(boost::units::cos(75.0 * degrees)), 0.2588, 0.0004);
+}
+
+BOOST_AUTO_TEST_CASE(test_tan) {
+ BOOST_CHECK_EQUAL(boost::units::tan(2.0 * radians), std::tan(2.0) * si_dimensionless);
+ BOOST_CHECK_CLOSE_FRACTION(static_cast<double>(boost::units::tan(45.0 * degrees)), 1.0, 0.0001);
+}
+
+BOOST_AUTO_TEST_CASE(test_asin) {
+ BOOST_CHECK_EQUAL(boost::units::asin(0.2 * si_dimensionless), std::asin(0.2) * radians);
+ BOOST_CHECK_CLOSE_FRACTION(boost::units::asin(0.5 * degree_dimensionless).value(), 30.0, 0.0001);
+ BOOST_CHECK_EQUAL(boost::units::asin(0.2 * heterogeneous_dimensionless).value(), std::asin(0.2));
+}
+
+BOOST_AUTO_TEST_CASE(test_acos) {
+ BOOST_CHECK_EQUAL(boost::units::acos(0.2 * si_dimensionless), std::acos(0.2) * radians);
+ BOOST_CHECK_CLOSE_FRACTION(boost::units::acos(0.5 * degree_dimensionless).value(), 60.0, 0.0001);
+ BOOST_CHECK_EQUAL(boost::units::acos(0.2 * heterogeneous_dimensionless).value(), std::acos(0.2));
+}
+
+BOOST_AUTO_TEST_CASE(test_atan) {
+ BOOST_CHECK_EQUAL(boost::units::atan(0.2 * si_dimensionless), std::atan(0.2) * radians);
+ BOOST_CHECK_CLOSE_FRACTION(boost::units::atan(1.0 * degree_dimensionless).value(), 45.0, 0.0001);
+ BOOST_CHECK_EQUAL(boost::units::atan(0.2 * heterogeneous_dimensionless).value(), std::atan(0.2));
+}
+
+BOOST_AUTO_TEST_CASE(test_atan2) {
+ BOOST_CHECK_EQUAL(boost::units::atan2(0.2 * si_dimensionless, 0.3 * si_dimensionless), std::atan2(0.2, 0.3) * radians);
+ BOOST_CHECK_EQUAL(boost::units::atan2(0.2 * meters, 0.3 * meters), std::atan2(0.2, 0.3) * radians);
+ BOOST_CHECK_CLOSE_FRACTION(boost::units::atan2(0.8660*degree_dimensionless,0.5*degree_dimensionless).value(), 60., 0.0002);
+ BOOST_CHECK_EQUAL(boost::units::atan2(0.2 * heterogeneous_dimensionless, 0.3 * heterogeneous_dimensionless).value(), std::atan2(0.2, 0.3));
+}
diff --git a/src/boost/libs/units/test/test_unit.cpp b/src/boost/libs/units/test/test_unit.cpp
new file mode 100644
index 000000000..ed80430fb
--- /dev/null
+++ b/src/boost/libs/units/test/test_unit.cpp
@@ -0,0 +1,67 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2008 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)
+
+/**
+\file
+
+\brief test_units_1.cpp
+
+\details
+Test unit class.
+
+Output:
+@verbatim
+@endverbatim
+**/
+
+#include "test_header.hpp"
+
+#include <boost/units/pow.hpp>
+
+namespace bu = boost::units;
+
+int test_main(int,char *[])
+{
+ BOOST_CONSTEXPR_OR_CONST bu::dimensionless D;
+
+ BOOST_CONSTEXPR_OR_CONST bu::length L;
+ BOOST_CONSTEXPR_OR_CONST bu::mass M;
+ BOOST_CONSTEXPR_OR_CONST bu::time T;
+
+ BOOST_CHECK(+L == L);
+ BOOST_CHECK(-L == L);
+ BOOST_CHECK(L+L == L);
+ BOOST_CHECK(L-L == L);
+
+ BOOST_CHECK(+M == M);
+ BOOST_CHECK(-M == M);
+ BOOST_CHECK(M+M == M);
+ BOOST_CHECK(M-M == M);
+
+ BOOST_CONSTEXPR_OR_CONST bu::area A;
+ BOOST_CONSTEXPR_OR_CONST bu::energy E;
+ BOOST_CONSTEXPR_OR_CONST bu::velocity V;
+
+ BOOST_CHECK(L*L == A);
+ BOOST_CHECK(A == L*L);
+
+ BOOST_CHECK(L/L == D);
+ BOOST_CHECK(D == L/L);
+
+ BOOST_CHECK(L/T == V);
+ BOOST_CHECK(V == L/T);
+
+ BOOST_CHECK(M*L*L/T/T == E);
+ BOOST_CHECK(M*(L/T)*(L/T) == E);
+ BOOST_CHECK(M*bu::pow<2>(L/T) == E);
+ BOOST_CHECK(bu::root<2>(E/M) == V);
+
+ return 0;
+}
diff --git a/src/boost/libs/units/test/test_unscale.cpp b/src/boost/libs/units/test/test_unscale.cpp
new file mode 100644
index 000000000..d81a144d5
--- /dev/null
+++ b/src/boost/libs/units/test/test_unscale.cpp
@@ -0,0 +1,58 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2007-2008 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)
+
+/**
+\file
+
+\brief test_unscale.cpp
+
+\details
+Test that unscale works in an attempt to isolate the sun problems.
+
+Output:
+@verbatim
+@endverbatim
+**/
+
+#include <boost/units/reduce_unit.hpp>
+#include <boost/units/detail/unscale.hpp>
+#include <boost/units/base_units/temperature/fahrenheit.hpp>
+
+#include <boost/mpl/assert.hpp>
+#include <boost/type_traits/is_same.hpp>
+
+BOOST_MPL_ASSERT((boost::is_same<boost::units::unscale<boost::units::temperature::fahrenheit_base_unit::unit_type::system_type>::type,
+ boost::units::temperature::fahrenheit_base_unit::unit_type::system_type>));
+
+BOOST_MPL_ASSERT((boost::is_same<boost::units::unscale<boost::units::temperature::fahrenheit_base_unit::unit_type>::type,
+ boost::units::temperature::fahrenheit_base_unit::unit_type>));
+
+BOOST_MPL_ASSERT((boost::is_same<boost::units::unscale<boost::units::reduce_unit<boost::units::temperature::fahrenheit_base_unit::unit_type>::type>::type,
+ boost::units::temperature::fahrenheit_base_unit::unit_type>));
+
+BOOST_MPL_ASSERT((boost::is_same<
+ boost::units::temperature::fahrenheit_base_unit::unit_type,
+ boost::units::unit<
+ boost::units::temperature_dimension,
+ boost::units::heterogeneous_system<
+ boost::units::heterogeneous_system_impl<
+ boost::units::list<
+ boost::units::heterogeneous_system_dim<
+ boost::units::temperature::fahrenheit_base_unit,
+ boost::units::static_rational<1>
+ >,
+ boost::units::dimensionless_type
+ >,
+ boost::units::temperature_dimension,
+ boost::units::dimensionless_type
+ >
+ >
+ >
+>));
diff --git a/src/boost/libs/units/test_headers/Jamfile.v2 b/src/boost/libs/units/test_headers/Jamfile.v2
new file mode 100644
index 000000000..8bcd8322a
--- /dev/null
+++ b/src/boost/libs/units/test_headers/Jamfile.v2
@@ -0,0 +1,56 @@
+# Jamfile.v2
+#
+# Copyright (c) 2007-2008
+# 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
+
+import testing ;
+import path ;
+import regex ;
+import print ;
+import sequence ;
+import feature ;
+
+project boost/units/test_headers :
+ requirements <include>$(BOOST_ROOT) <include>../../..
+;
+
+headers = [ path.glob-tree ../../../boost/units : *.hpp : detail ] ;
+
+for local file in $(headers)
+{
+ compile test.cpp
+ : # requirements
+ <define>BOOST_UNITS_HEADER_NAME=$(file)
+ <dependency>$(file)
+ : # test name
+ [ regex.replace [ path.relative-to ../../.. $(file) ] "/" "_" ] ;
+}
+
+feature.feature <generate-include-all-order> : forward reverse : incidental ;
+
+rule generate-include-all ( target : sources * : properties * )
+{
+ print.output $(target) ;
+
+ if <generate-include-all-order>reverse in $(properties)
+ {
+ sources = [ sequence.reverse $(sources) ] ;
+ }
+
+ for local file in $(sources)
+ {
+ print.text "#include <$(file:G=)>
+" : overwrite ;
+ }
+
+}
+
+make include_all1.cpp : $(headers) : @generate-include-all ;
+make include_all2.cpp : $(headers) : @generate-include-all : <generate-include-all-order>reverse ;
+
+# this ought to catch non-inlined functions and other duplicate definitions
+link include_all1.cpp include_all2.cpp main.cpp : <include>. : include_all_headers ;
diff --git a/src/boost/libs/units/test_headers/main.cpp b/src/boost/libs/units/test_headers/main.cpp
new file mode 100644
index 000000000..a7746ff48
--- /dev/null
+++ b/src/boost/libs/units/test_headers/main.cpp
@@ -0,0 +1,12 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2007-2008 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)
+
+int main() {
+}
diff --git a/src/boost/libs/units/test_headers/test.cpp b/src/boost/libs/units/test_headers/test.cpp
new file mode 100644
index 000000000..589e974c0
--- /dev/null
+++ b/src/boost/libs/units/test_headers/test.cpp
@@ -0,0 +1,19 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2007-2008 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)
+
+#define BOOST_UNITS_STRINGIZE_IMPL(x) #x
+#define BOOST_UNITS_STRINGIZE(x) BOOST_UNITS_STRINGIZE_IMPL(x)
+
+#define BOOST_UNITS_HEADER BOOST_UNITS_STRINGIZE(BOOST_UNITS_HEADER_NAME)
+
+#include BOOST_UNITS_HEADER
+#include BOOST_UNITS_HEADER
+
+int main() {}
diff --git a/src/boost/libs/units/tutorial/tutorial_1.cpp b/src/boost/libs/units/tutorial/tutorial_1.cpp
new file mode 100644
index 000000000..f7508a6c1
--- /dev/null
+++ b/src/boost/libs/units/tutorial/tutorial_1.cpp
@@ -0,0 +1,314 @@
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2008 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)
+
+#include <iostream>
+
+#include <boost/units/units_fwd.hpp>
+
+#include <boost/units/base_dimension.hpp>
+#include <boost/units/base_unit.hpp>
+#include <boost/units/derived_dimension.hpp>
+#include <boost/units/make_system.hpp>
+#include <boost/units/io.hpp>
+#include <boost/units/quantity.hpp>
+#include <boost/units/static_constant.hpp>
+#include <boost/units/unit.hpp>
+
+namespace boost {
+
+namespace units {
+
+struct length_base_dimension : boost::units::base_dimension<length_base_dimension,1> { }; ///> base dimension of length
+struct time_base_dimension : boost::units::base_dimension<time_base_dimension,3> { }; ///> base dimension of time
+
+typedef length_base_dimension::dimension_type length_dimension;
+typedef time_base_dimension::dimension_type time_dimension;
+
+struct length1_base_unit : base_unit<length1_base_unit,length_dimension,1>
+{
+ static std::string name() { return "length 1"; }
+ static std::string symbol() { return "l1"; }
+};
+
+struct length2_base_unit : base_unit<length2_base_unit,length_dimension,2>
+{
+ static std::string name() { return "length2"; }
+ static std::string symbol() { return "l2"; }
+};
+
+struct time1_base_unit : base_unit<time1_base_unit,time_dimension,3>
+{
+ static std::string name() { return "time1"; }
+ static std::string symbol() { return "t1"; }
+};
+
+struct time2_base_unit : base_unit<time2_base_unit,time_dimension,4>
+{
+ static std::string name() { return "time2"; }
+ static std::string symbol() { return "t2"; }
+};
+
+namespace s1 {
+
+typedef make_system<length1_base_unit,time1_base_unit>::type system;
+
+/// unit typedefs
+typedef unit<dimensionless_type,system> dimensionless;
+
+typedef unit<length_dimension,system> length;
+typedef unit<time_dimension,system> time;
+
+/// unit constants
+BOOST_UNITS_STATIC_CONSTANT(length1,length);
+BOOST_UNITS_STATIC_CONSTANT(time1,time);
+
+} // namespace s1
+
+namespace s2 {
+
+typedef make_system<length2_base_unit,time2_base_unit>::type system;
+
+/// unit typedefs
+typedef unit<dimensionless_type,system> dimensionless;
+
+typedef unit<length_dimension,system> length;
+typedef unit<time_dimension,system> time;
+
+/// unit constants
+BOOST_UNITS_STATIC_CONSTANT(length2,length);
+BOOST_UNITS_STATIC_CONSTANT(time2,time);
+
+} // namespace s2
+
+template<class X,class Y>
+struct conversion_helper< quantity<s1::length,X>,quantity<s2::length,Y> >
+{
+ static quantity<s2::length,Y> convert(const quantity<s1::length,X>& source)
+ {
+ return quantity<s2::length,Y>::from_value(2.5*source.value());
+ }
+};
+
+template<class X,class Y>
+struct conversion_helper< quantity<s2::length,X>,quantity<s1::length,Y> >
+{
+ static quantity<s1::length,Y> convert(const quantity<s2::length,X>& source)
+ {
+ return quantity<s1::length,Y>::from_value((1.0/2.5)*source.value());
+ }
+};
+
+template<class X,class Y>
+struct conversion_helper< quantity<s1::time,X>,quantity<s2::time,Y> >
+{
+ static quantity<s2::time,Y> convert(const quantity<s1::time,X>& source)
+ {
+ return quantity<s2::time,Y>::from_value(0.5*source.value());
+ }
+};
+
+} // namespace units
+
+} // namespace boost
+
+int main(void)
+{
+ using namespace boost::units;
+
+ quantity<s1::length,float> l1(1.0*s1::length1);
+ quantity<s2::length,double> l2(1.5*l1);
+ quantity<s1::length,float> l3(2.0*l2/3.0);
+
+ quantity<s1::time,float> t1(1.0*s1::time1);
+ quantity<s2::time,double> t2(1.5*t1);
+// quantity<s1::time,float> t3(2.0*t2/3.0);
+
+ return 0;
+}
+
+/*
+// Boost.Units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2008 Matthias Christian Schabel
+// Copyright (C) 2008 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)
+
+#include <iostream>
+
+#include <boost/units/units_fwd.hpp>
+
+#include <boost/units/base_dimension.hpp>
+#include <boost/units/base_unit.hpp>
+#include <boost/units/derived_dimension.hpp>
+#include <boost/units/make_system.hpp>
+#include <boost/units/io.hpp>
+#include <boost/units/quantity.hpp>
+#include <boost/units/static_constant.hpp>
+#include <boost/units/unit.hpp>
+
+namespace boost {
+
+namespace units {
+
+struct length_base_dimension : boost::units::base_dimension<length_base_dimension,1> { }; ///> base dimension of length
+struct mass_base_dimension : boost::units::base_dimension<mass_base_dimension,2> { }; ///> base dimension of mass
+struct time_base_dimension : boost::units::base_dimension<time_base_dimension,3> { }; ///> base dimension of time
+
+typedef length_base_dimension::dimension_type length_dimension;
+typedef mass_base_dimension::dimension_type mass_dimension;
+typedef time_base_dimension::dimension_type time_dimension;
+
+struct centimeter_base_unit : base_unit<centimeter_base_unit,length_dimension,1>
+{
+ static std::string name() { return "centimeter"; }
+ static std::string symbol() { return "cm"; }
+};
+
+struct gram_base_unit : base_unit<gram_base_unit,mass_dimension,2>
+{
+ static std::string name() { return "gram"; }
+ static std::string symbol() { return "g"; }
+};
+
+struct second_base_unit : base_unit<second_base_unit,time_dimension,3>
+{
+ static std::string name() { return "second"; }
+ static std::string symbol() { return "s"; }
+};
+
+namespace CG {
+
+typedef make_system<centimeter_base_unit,gram_base_unit>::type system;
+
+/// unit typedefs
+typedef unit<dimensionless_type,system> dimensionless;
+
+typedef unit<length_dimension,system> length;
+typedef unit<mass_dimension,system> mass;
+
+/// unit constants
+BOOST_UNITS_STATIC_CONSTANT(centimeter,length);
+BOOST_UNITS_STATIC_CONSTANT(gram,mass);
+
+} // namespace CG
+
+namespace cgs {
+
+typedef make_system<centimeter_base_unit,gram_base_unit,second_base_unit>::type system;
+
+/// unit typedefs
+typedef unit<dimensionless_type,system> dimensionless;
+
+typedef unit<length_dimension,system> length;
+typedef unit<mass_dimension,system> mass;
+typedef unit<time_dimension,system> time;
+
+/// unit constants
+BOOST_UNITS_STATIC_CONSTANT(centimeter,length);
+BOOST_UNITS_STATIC_CONSTANT(gram,mass);
+BOOST_UNITS_STATIC_CONSTANT(second,time);
+
+} // namespace cgs
+
+namespace esu {
+
+typedef make_system<centimeter_base_unit,
+ gram_base_unit,
+ second_base_unit>::type system;
+
+/// derived dimension for force in electrostatic units : L M T^-2
+typedef derived_dimension<length_base_dimension,1,
+ mass_base_dimension,1,
+ time_base_dimension,-2>::type force_dimension;
+
+/// derived dimension for charge in electrostatic units : L^3/2 M^1/2 T^-1
+typedef make_dimension_list< mpl::list< dim<length_base_dimension,static_rational<3,2> >,
+ dim<mass_base_dimension,static_rational<1,2> >,
+ dim<time_base_dimension,static_rational<-1> > > >::type charge_dimension;
+
+/// derived dimension for current in electrostatic units : L^3/2 M^1/2 T^-2
+typedef make_dimension_list< mpl::list< dim<length_base_dimension,static_rational<3,2> >,
+ dim<mass_base_dimension,static_rational<1,2> >,
+ dim<time_base_dimension,static_rational<-2> > > >::type current_dimension;
+
+/// derived dimension for electric potential in electrostatic units : L^1/2 M^1/2 T^-1
+typedef make_dimension_list< mpl::list< dim<length_base_dimension,static_rational<1,2> >,
+ dim<mass_base_dimension,static_rational<1,2> >,
+ dim<time_base_dimension,static_rational<-1> > > >::type electric_potential_dimension;
+
+/// derived dimension for electric field in electrostatic units : L^-1/2 M^1/2 T^-1
+typedef make_dimension_list< mpl::list< dim<length_base_dimension,static_rational<-1,2> >,
+ dim<mass_base_dimension,static_rational<1,2> >,
+ dim<time_base_dimension,static_rational<-1> > > >::type electric_field_dimension;
+
+/// unit typedefs
+typedef unit<dimensionless_type,system> dimensionless;
+
+typedef unit<length_dimension,system> length;
+typedef unit<mass_dimension,system> mass;
+typedef unit<time_dimension,system> time;
+
+typedef unit<force_dimension,system> force;
+
+typedef unit<charge_dimension,system> charge;
+typedef unit<current_dimension,system> current;
+typedef unit<electric_potential_dimension,system> electric_potential;
+typedef unit<electric_field_dimension,system> electric_field;
+
+/// unit constants
+BOOST_UNITS_STATIC_CONSTANT(centimeter,length);
+BOOST_UNITS_STATIC_CONSTANT(gram,mass);
+BOOST_UNITS_STATIC_CONSTANT(second,time);
+
+BOOST_UNITS_STATIC_CONSTANT(dyne,force);
+
+BOOST_UNITS_STATIC_CONSTANT(esu,charge);
+BOOST_UNITS_STATIC_CONSTANT(statvolt,electric_potential);
+
+} // namespace esu
+
+template<class Y>
+quantity<esu::force,Y> coulombLaw(const quantity<esu::charge,Y>& q1,
+ const quantity<esu::charge,Y>& q2,
+ const quantity<esu::length,Y>& r)
+{
+ return q1*q2/(r*r);
+}
+
+} // namespace units
+
+} // namespace boost
+
+int main(void)
+{
+ using namespace boost::units;
+
+ quantity<CG::length> cg_length(1.0*CG::centimeter);
+ quantity<cgs::length> cgs_length(1.0*cgs::centimeter);
+
+ std::cout << cg_length/cgs_length << std::endl;
+
+ std::cout << esu::gram*pow<2>(esu::centimeter/esu::second)/esu::esu << std::endl;
+ std::cout << esu::statvolt/esu::centimeter << std::endl;
+
+ quantity<esu::charge> q1 = 1.0*esu::esu,
+ q2 = 2.0*esu::esu;
+ quantity<esu::length> r = 1.0*esu::centimeter;
+
+ std::cout << coulombLaw(q1,q2,r) << std::endl;
+ std::cout << coulombLaw(q1,q2,cgs_length) << std::endl;
+
+ return 0;
+}
+*/