summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/units/example
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/example
parentInitial commit. (diff)
downloadceph-upstream.tar.xz
ceph-upstream.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 '')
-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
25 files changed, 4949 insertions, 0 deletions
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;
+}