|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r50236 - in branches/release: boost/units boost/units/base_units/temperature boost/units/detail libs/units/doc libs/units/example libs/units/test libs/units/test_headers
From: steven_at_[hidden]
Date: 2008-12-10 22:09:10
Author: steven_watanabe
Date: 2008-12-10 22:09:08 EST (Wed, 10 Dec 2008)
New Revision: 50236
URL: http://svn.boost.org/trac/boost/changeset/50236
Log:
Merge compiler workarounds, construction from a literal 0, and use of a couple Boost.Math functions from trunk
Added:
branches/release/libs/units/test/test_reduce_unit.cpp
- copied unchanged from r50235, /trunk/libs/units/test/test_reduce_unit.cpp
branches/release/libs/units/test/test_unscale.cpp
- copied unchanged from r50235, /trunk/libs/units/test/test_unscale.cpp
Text files modified:
branches/release/boost/units/base_dimension.hpp | 6
branches/release/boost/units/base_unit.hpp | 6
branches/release/boost/units/base_units/temperature/conversions.hpp | 2
branches/release/boost/units/cmath.hpp | 13 +--
branches/release/boost/units/config.hpp | 20 ++--
branches/release/boost/units/detail/conversion_impl.hpp | 16 ++-
branches/release/boost/units/detail/dimensionless_unit.hpp | 51 +++++++------
branches/release/boost/units/detail/linear_algebra.hpp | 14 ---
branches/release/boost/units/detail/one.hpp | 14 ++
branches/release/boost/units/detail/prevent_redefinition.hpp | 6
branches/release/boost/units/detail/static_rational_power.hpp | 14 ++-
branches/release/boost/units/detail/unscale.hpp | 5
branches/release/boost/units/detail/utility.hpp | 11 --
branches/release/boost/units/homogeneous_system.hpp | 2
branches/release/boost/units/lambda.hpp | 45 +++++++++++
branches/release/boost/units/pow.hpp | 11 ++
branches/release/boost/units/quantity.hpp | 10 ++
branches/release/boost/units/scale.hpp | 6
branches/release/boost/units/static_rational.hpp | 154 ++++++++++++++++++++++++++++++++++++++-
branches/release/libs/units/doc/Jamfile.v2 | 112 ++++++++++++++++++----------
branches/release/libs/units/example/Jamfile.v2 | 25 ++----
branches/release/libs/units/test/Jamfile.v2 | 103 +++++++++++--------------
branches/release/libs/units/test/test_cmath.cpp | 5 -
branches/release/libs/units/test/test_conversion.cpp | 32 ++++---
branches/release/libs/units/test/test_lambda.cpp | 12 +++
branches/release/libs/units/test_headers/Jamfile.v2 | 48 ++++++------
26 files changed, 483 insertions(+), 260 deletions(-)
Modified: branches/release/boost/units/base_dimension.hpp
==============================================================================
--- branches/release/boost/units/base_dimension.hpp (original)
+++ branches/release/boost/units/base_dimension.hpp 2008-12-10 22:09:08 EST (Wed, 10 Dec 2008)
@@ -50,7 +50,7 @@
/// to use the same value in multiple definitions.
template<class Derived,
long N
-#ifndef BOOST_UNITS_DOXYGEN
+#if !defined(BOOST_UNITS_DOXYGEN) && !defined(__BORLANDC__)
,
class = typename detail::ordinal_has_already_been_defined<
check_base_dimension<Derived, N>::value
@@ -77,13 +77,13 @@
/// INTERNAL ONLY
friend detail::yes
boost_units_is_registered(const units::base_dimension_ordinal<N>&)
- { return(detail::yes()); }
+ { detail::yes result; return(result); }
/// But make sure we can identify the current instantiation!
/// INTERNAL ONLY
friend detail::yes
boost_units_is_registered(const units::base_dimension_pair<Derived, N>&)
- { return(detail::yes()); }
+ { detail::yes result; return(result); }
};
} // namespace units
Modified: branches/release/boost/units/base_unit.hpp
==============================================================================
--- branches/release/boost/units/base_unit.hpp (original)
+++ branches/release/boost/units/base_unit.hpp 2008-12-10 22:09:08 EST (Wed, 10 Dec 2008)
@@ -53,7 +53,7 @@
template<class Derived,
class Dim,
long N
-#ifndef BOOST_UNITS_DOXYGEN
+#if !defined(BOOST_UNITS_DOXYGEN) && !defined(__BORLANDC__)
,
class = typename detail::ordinal_has_already_been_defined<
check_base_unit<Derived, N>::value
@@ -98,13 +98,13 @@
/// INTERNAL ONLY
friend detail::yes
boost_units_unit_is_registered(const units::base_unit_ordinal<N>&)
- { return(detail::yes()); }
+ { detail::yes result; return(result); }
/// But make sure we can identify the current instantiation!
/// INTERNAL ONLY
friend detail::yes
boost_units_unit_is_registered(const units::base_unit_pair<Derived, N>&)
- { return(detail::yes()); }
+ { detail::yes result; return(result); }
};
} // namespace units
Modified: branches/release/boost/units/base_units/temperature/conversions.hpp
==============================================================================
--- branches/release/boost/units/base_units/temperature/conversions.hpp (original)
+++ branches/release/boost/units/base_units/temperature/conversions.hpp 2008-12-10 22:09:08 EST (Wed, 10 Dec 2008)
@@ -18,7 +18,7 @@
#define BOOST_UNITS_SYSTEMS_KELVIN_TO_CELSIUS_CONVERSION_DEFINED
#include <boost/units/conversion.hpp>
#include <boost/units/absolute.hpp>
- BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::si::kelvin_base_unit, boost::units::temperature::celsius_base_unit, one, one());
+ BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::si::kelvin_base_unit, boost::units::temperature::celsius_base_unit, one, make_one());
BOOST_UNITS_DEFINE_CONVERSION_OFFSET(boost::units::si::kelvin_base_unit, boost::units::temperature::celsius_base_unit, double, -273.15);
#endif
Modified: branches/release/boost/units/cmath.hpp
==============================================================================
--- branches/release/boost/units/cmath.hpp (original)
+++ branches/release/boost/units/cmath.hpp 2008-12-10 22:09:08 EST (Wed, 10 Dec 2008)
@@ -24,8 +24,8 @@
#include <boost/math/special_functions/fpclassify.hpp>
#include <boost/math/special_functions/hypot.hpp>
-//#include <boost/math/special_functions/next.hpp>
-//#include <boost/math/special_functions/round.hpp>
+#include <boost/math/special_functions/next.hpp>
+#include <boost/math/special_functions/round.hpp>
#include <boost/math/special_functions/sign.hpp>
#include <boost/units/dimensionless_quantity.hpp>
@@ -349,9 +349,6 @@
#endif
-// these are not in the release branch yet
-#if 0
-
template<class Unit,class Y>
inline
quantity<Unit,Y> nextafter BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit,Y>& q1,
@@ -378,8 +375,6 @@
return quantity_type::from_value(nextafter BOOST_PREVENT_MACRO_SUBSTITUTION (q1.value(),q2.value()));
}
-#endif
-
#if 0
template<class Unit,class Y>
@@ -394,6 +389,8 @@
return quantity_type::from_value(rint BOOST_PREVENT_MACRO_SUBSTITUTION (q.value()));
}
+#endif
+
template<class Unit,class Y>
inline
quantity<Unit,Y>
@@ -406,8 +403,6 @@
return quantity_type::from_value(round BOOST_PREVENT_MACRO_SUBSTITUTION (q.value()));
}
-#endif
-
template<class Unit,class Y>
inline
int
Modified: branches/release/boost/units/config.hpp
==============================================================================
--- branches/release/boost/units/config.hpp (original)
+++ branches/release/boost/units/config.hpp 2008-12-10 22:09:08 EST (Wed, 10 Dec 2008)
@@ -14,17 +14,15 @@
#include <boost/config.hpp>
#include <boost/version.hpp>
-#if (BOOST_VERSION >= 103400)
- ///INTERNAL ONLY
- #define BOOST_UNITS_HAS_BOOST_TYPEOF 1
-#else
- ///INTERNAL ONLY
- #define BOOST_UNITS_HAS_BOOST_TYPEOF 0
-#endif
-
-// uncomment this to test without Boost Typeof
-//#undef BOOST_UNITS_HAS_BOOST_TYPEOF
-//#define BOOST_UNITS_HAS_BOOST_TYPEOF 0
+#ifndef BOOST_UNITS_HAS_BOOST_TYPEOF
+ #if (BOOST_VERSION >= 103400)
+ ///INTERNAL ONLY
+ #define BOOST_UNITS_HAS_BOOST_TYPEOF 1
+ #else
+ ///INTERNAL ONLY
+ #define BOOST_UNITS_HAS_BOOST_TYPEOF 0
+ #endif
+#endif
#if (BOOST_UNITS_HAS_BOOST_TYPEOF)
#include <boost/typeof/typeof.hpp>
Modified: branches/release/boost/units/detail/conversion_impl.hpp
==============================================================================
--- branches/release/boost/units/detail/conversion_impl.hpp (original)
+++ branches/release/boost/units/detail/conversion_impl.hpp 2008-12-10 22:09:08 EST (Wed, 10 Dec 2008)
@@ -113,7 +113,8 @@
static const bool is_defined = true;
typedef one type;
static type value() {
- return(one());
+ one result;
+ return(result);
}
};
@@ -172,7 +173,8 @@
typedef do_call_base_unit_converter<Dest, typename Source::unit_type> converter;
typedef typename divide_typeof_helper<one, typename converter::type>::type type;
static type value() {
- return(one() / converter::value());
+ one numerator;
+ return(numerator / converter::value());
}
};
};
@@ -232,8 +234,9 @@
{
typedef unit<dimensionless_type, heterogeneous_system<heterogeneous_system_impl<dimensionless_type, dimensionless_type, no_scale> > > unit_type;
typedef one type;
- static type value() {
- return(type());
+ static one value() {
+ one result;
+ return(result);
}
};
};
@@ -322,7 +325,7 @@
struct apply
{
typedef one type;
- static type value() { return(one()); }
+ static type value() { one result; return(result); }
};
};
@@ -482,7 +485,8 @@
typedef typename multiply_typeof_helper<typename impl::type, typename scale::type>::type type;
static type value()
{
- return(one() / (impl::value() * scale::value()));
+ one numerator;
+ return(numerator / (impl::value() * scale::value()));
}
};
Modified: branches/release/boost/units/detail/dimensionless_unit.hpp
==============================================================================
--- branches/release/boost/units/detail/dimensionless_unit.hpp (original)
+++ branches/release/boost/units/detail/dimensionless_unit.hpp 2008-12-10 22:09:08 EST (Wed, 10 Dec 2008)
@@ -11,7 +11,6 @@
#ifndef BOOST_UNITS_DETAIL_DIMENSIONLESS_UNIT_HPP
#define BOOST_UNITS_DETAIL_DIMENSIONLESS_UNIT_HPP
-#include <boost/utility/enable_if.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/units/units_fwd.hpp>
@@ -29,14 +28,18 @@
namespace detail {
-template<class T>
-struct is_dimensionless_system : boost::mpl::false_ {};
+template<class System>
+struct void_if_dimensionless {
+ typedef int type;
+};
template<class T>
-struct is_dimensionless_system<boost::units::homogeneous_system<T> > : boost::mpl::true_ {};
+struct void_if_dimensionless<boost::units::homogeneous_system<T> > {
+ typedef void type;
+};
template<>
-struct is_dimensionless_system<
+struct void_if_dimensionless<
boost::units::heterogeneous_system<
boost::units::heterogeneous_system_impl<
boost::units::dimensionless_type,
@@ -44,40 +47,40 @@
boost::units::dimensionless_type
>
>
-> : boost::mpl::true_ {};
+> {
+ typedef void type;
+};
+
+template<class System, class Test = void>
+struct void_if_heterogeneous {
+ typedef void type;
+};
+
+template<class System>
+struct void_if_heterogeneous<System, typename void_if_dimensionless<System>::type> {
+ typedef int type;
+};
-#ifdef BOOST_MSVC
+template<class System, class Enable=void>
+struct is_dimensionless_system : mpl::false_ {};
-#define BOOST_UNITS_DIMENSIONLESS_UNIT(T)\
- boost::units::unit<\
- typename boost::enable_if<boost::units::detail::is_dimensionless_system<T>, boost::units::dimensionless_type>::type,\
- T\
- >
-
-#define BOOST_UNITS_HETEROGENEOUS_DIMENSIONLESS_UNIT(T)\
- boost::units::unit<\
- typename boost::disable_if<boost::units::detail::is_dimensionless_system<T>, boost::units::dimensionless_type>::type,\
- T\
- >
-
-#else
+template<class System>
+struct is_dimensionless_system<System, typename void_if_dimensionless<System>::type> : mpl::true_ {};
#define BOOST_UNITS_DIMENSIONLESS_UNIT(T)\
boost::units::unit<\
boost::units::dimensionless_type,\
T,\
- typename boost::enable_if<boost::units::detail::is_dimensionless_system<T> >::type\
+ typename ::boost::units::detail::void_if_dimensionless<T>::type\
>
#define BOOST_UNITS_HETEROGENEOUS_DIMENSIONLESS_UNIT(T)\
boost::units::unit<\
boost::units::dimensionless_type,\
T,\
- typename boost::disable_if<boost::units::detail::is_dimensionless_system<T> >::type\
+ typename ::boost::units::detail::void_if_heterogeneous<T>::type\
>
-#endif
-
}
}
}
Modified: branches/release/boost/units/detail/linear_algebra.hpp
==============================================================================
--- branches/release/boost/units/detail/linear_algebra.hpp (original)
+++ branches/release/boost/units/detail/linear_algebra.hpp 2008-12-10 22:09:08 EST (Wed, 10 Dec 2008)
@@ -952,20 +952,6 @@
// dimension.
//
// list<rational> calculate_base_unit_exponents(list<base_unit> units, dimension_list dimensions);
-//
-// What is the purpose of all this magic with
-// base_dimensions? Can't we just solve the
-// equations for the dimension directly? Yes,
-// we can, but remember that solving a
-// system of linear equations is O(N^3).
-// By normalizing the system we incur a
-// high one time cost O(N^4), but for all
-// solutions after the first it is O(N^2)
-// In addition, the constant factor is
-// good because everything is already set up.
-// Since we expect a few systems to be
-// used many times, the cost of creating
-// a system is probably not significant.
template<class T>
struct is_base_dimension_unit {
Modified: branches/release/boost/units/detail/one.hpp
==============================================================================
--- branches/release/boost/units/detail/one.hpp (original)
+++ branches/release/boost/units/detail/one.hpp 2008-12-10 22:09:08 EST (Wed, 10 Dec 2008)
@@ -17,7 +17,13 @@
namespace units {
-struct one { };
+struct one { one() {} };
+
+// workaround for pathscale.
+inline one make_one() {
+ one result;
+ return(result);
+}
template<class T>
struct multiply_typeof_helper<one, T>
@@ -51,7 +57,8 @@
inline one operator*(const one&, const one&)
{
- return(one());
+ one result;
+ return(result);
}
template<class T>
@@ -86,7 +93,8 @@
inline one operator/(const one&, const one&)
{
- return(one());
+ one result;
+ return(result);
}
} // namespace units
Modified: branches/release/boost/units/detail/prevent_redefinition.hpp
==============================================================================
--- branches/release/boost/units/detail/prevent_redefinition.hpp (original)
+++ branches/release/boost/units/detail/prevent_redefinition.hpp 2008-12-10 22:09:08 EST (Wed, 10 Dec 2008)
@@ -19,7 +19,7 @@
namespace detail {
-typedef char no;
+struct no { no() {} char dummy; };
struct yes { no dummy[2]; };
template<bool> struct ordinal_has_already_been_defined;
@@ -39,13 +39,13 @@
template<class T>
detail::no
boost_units_is_registered(const T&)
-{ return(detail::no()); }
+{ detail::no result; return(result); }
/// INTERNAL ONLY
template<class T>
detail::no
boost_units_unit_is_registered(const T&)
-{ return(detail::no()); }
+{ detail::no result; return(result); }
} // namespace units
Modified: branches/release/boost/units/detail/static_rational_power.hpp
==============================================================================
--- branches/release/boost/units/detail/static_rational_power.hpp (original)
+++ branches/release/boost/units/detail/static_rational_power.hpp 2008-12-10 22:09:08 EST (Wed, 10 Dec 2008)
@@ -2,7 +2,7 @@
// unit/quantity manipulation and conversion
//
// Copyright (C) 2003-2008 Matthias Christian Schabel
-// Copyright (C) 2008 Steven Watanabe
+// 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
@@ -63,7 +63,8 @@
typedef one type;
static one call(const one&)
{
- return(one());
+ one result;
+ return(result);
}
};
@@ -73,7 +74,8 @@
typedef one type;
static one call(const one&)
{
- return(one());
+ one result;
+ return(result);
}
};
@@ -156,7 +158,8 @@
typedef typename impl::type type;
static type call(const Y& y)
{
- return(impl::call(y, one()));
+ one result;
+ return(impl::call(y, result));
}
};
};
@@ -171,7 +174,8 @@
typedef typename divide_typeof_helper<one, typename impl::type>::type type;
static type call(const Y& y)
{
- return(one()/impl::call(y, one()));
+ one result;
+ return(result/impl::call(y, result));
}
};
};
Modified: branches/release/boost/units/detail/unscale.hpp
==============================================================================
--- branches/release/boost/units/detail/unscale.hpp (original)
+++ branches/release/boost/units/detail/unscale.hpp 2008-12-10 22:09:08 EST (Wed, 10 Dec 2008)
@@ -157,9 +157,10 @@
struct apply
{
typedef one type;
- static type value()
+ static one value()
{
- return(type());
+ one result;
+ return(result);
}
};
};
Modified: branches/release/boost/units/detail/utility.hpp
==============================================================================
--- branches/release/boost/units/detail/utility.hpp (original)
+++ branches/release/boost/units/detail/utility.hpp 2008-12-10 22:09:08 EST (Wed, 10 Dec 2008)
@@ -21,16 +21,13 @@
#include <boost/cstdint.hpp>
#include <boost/limits.hpp>
-#if (__GNUC__ && __cplusplus && __GNUC__ >= 3)
+#if defined(__GLIBCXX__) || defined(__GLIBCPP__)
#define BOOST_UNITS_USE_DEMANGLING
+#include <cxxabi.h>
#endif // __GNUC__
#ifdef BOOST_UNITS_USE_DEMANGLING
-#if (__GNUC__ && __cplusplus && __GNUC__ >= 3)
-#include <cxxabi.h>
-#endif // __GNUC__
-
#include <boost/algorithm/string/replace.hpp>
namespace boost {
@@ -43,7 +40,6 @@
std::string
demangle(const char* name)
{
- #if (__GNUC__ && __cplusplus && __GNUC__ >= 3)
// need to demangle C++ symbols
char* realname;
std::size_t len;
@@ -69,9 +65,6 @@
}
return std::string("demangle :: error - unable to demangle specified symbol");
- #else
- return name;
- #endif
}
} // namespace detail
Modified: branches/release/boost/units/homogeneous_system.hpp
==============================================================================
--- branches/release/boost/units/homogeneous_system.hpp (original)
+++ branches/release/boost/units/homogeneous_system.hpp 2008-12-10 22:09:08 EST (Wed, 10 Dec 2008)
@@ -18,7 +18,7 @@
#ifdef BOOST_UNITS_CHECK_HOMOGENEOUS_UNITS
-#include <boost/is_same.hpp>
+#include <boost/type_traits/is_same.hpp>
#include <boost/mpl/not.hpp>
#include <boost/units/detail/linear_algebra.hpp>
Modified: branches/release/boost/units/lambda.hpp
==============================================================================
--- branches/release/boost/units/lambda.hpp (original)
+++ branches/release/boost/units/lambda.hpp 2008-12-10 22:09:08 EST (Wed, 10 Dec 2008)
@@ -34,6 +34,7 @@
#include <boost/lambda/lambda.hpp>
#include <boost/units/units_fwd.hpp>
+#include <boost/units/detail/dimensionless_unit.hpp>
#include <boost/units/operators.hpp>
namespace boost {
@@ -318,6 +319,28 @@
};
/// Partial specialization of return type trait for action
+ /// quantity<dimensionless, X> + Y.
+ template<typename System, typename X, typename Y>
+ struct plain_return_type_2<arithmetic_action<plus_action>,
+ boost::units::quantity<BOOST_UNITS_DIMENSIONLESS_UNIT(System), X>,
+ Y> {
+ typedef typename boost::units::add_typeof_helper<
+ boost::units::quantity<BOOST_UNITS_DIMENSIONLESS_UNIT(System), X>,
+ Y>::type type;
+ };
+
+ /// Partial specialization of return type trait for action
+ /// X + quantity<dimensionless, Y>.
+ template<typename System, typename X, typename Y>
+ struct plain_return_type_2<arithmetic_action<plus_action>,
+ X,
+ boost::units::quantity<BOOST_UNITS_DIMENSIONLESS_UNIT(System), Y> > {
+ typedef typename boost::units::add_typeof_helper<
+ X,
+ boost::units::quantity<BOOST_UNITS_DIMENSIONLESS_UNIT(System), Y> >::type type;
+ };
+
+ /// Partial specialization of return type trait for action
/// quantity<Unit1, X> - quantity<Unit2, Y>.
template<typename Unit1, typename X, typename Unit2, typename Y>
struct plain_return_type_2<arithmetic_action<minus_action>,
@@ -329,6 +352,28 @@
};
/// Partial specialization of return type trait for action
+ /// quantity<dimensionless, X> - Y.
+ template<typename System, typename X, typename Y>
+ struct plain_return_type_2<arithmetic_action<minus_action>,
+ boost::units::quantity<BOOST_UNITS_DIMENSIONLESS_UNIT(System), X>,
+ Y> {
+ typedef typename boost::units::subtract_typeof_helper<
+ boost::units::quantity<BOOST_UNITS_DIMENSIONLESS_UNIT(System), X>,
+ Y>::type type;
+ };
+
+ /// Partial specialization of return type trait for action
+ /// X - quantity<dimensionless, Y>.
+ template<typename System, typename X, typename Y>
+ struct plain_return_type_2<arithmetic_action<minus_action>,
+ X,
+ boost::units::quantity<BOOST_UNITS_DIMENSIONLESS_UNIT(System), Y> > {
+ typedef typename boost::units::subtract_typeof_helper<
+ X,
+ boost::units::quantity<BOOST_UNITS_DIMENSIONLESS_UNIT(System), Y> >::type type;
+ };
+
+ /// Partial specialization of return type trait for action
/// quantity<Unit1, X> * quantity<Unit2, Y>.
template<typename Unit1, typename X, typename Unit2, typename Y>
struct plain_return_type_2<arithmetic_action<multiply_action>,
Modified: branches/release/boost/units/pow.hpp
==============================================================================
--- branches/release/boost/units/pow.hpp (original)
+++ branches/release/boost/units/pow.hpp 2008-12-10 22:09:08 EST (Wed, 10 Dec 2008)
@@ -60,7 +60,10 @@
/// raise @c float to a @c static_rational power
template<long N,long D>
struct power_typeof_helper<float, static_rational<N,D> >
- : power_typeof_helper<double, static_rational<N,D> > {};
+ : power_typeof_helper<double, static_rational<N,D> > {
+ typedef typename power_typeof_helper<double, static_rational<N,D> >::type type;
+ using power_typeof_helper<double, static_rational<N,D> >::value;
+};
#endif
@@ -85,7 +88,11 @@
/// take @c static_rational root of an @c T
template<class T, long N,long D>
struct root_typeof_helper<T,static_rational<N,D> >
- : power_typeof_helper<T, static_rational<D,N> > {};
+ : power_typeof_helper<T, static_rational<D,N> > {
+ // help pathscale?
+ typedef typename power_typeof_helper<T, static_rational<D,N> >::type type;
+ using power_typeof_helper<T, static_rational<D,N> >::value;
+};
#endif
Modified: branches/release/boost/units/quantity.hpp
==============================================================================
--- branches/release/boost/units/quantity.hpp (original)
+++ branches/release/boost/units/quantity.hpp 2008-12-10 22:09:08 EST (Wed, 10 Dec 2008)
@@ -91,6 +91,7 @@
// base units are not the same as units.
BOOST_MPL_ASSERT_NOT((detail::is_base_unit<Unit>));
enum { force_instantiation_of_unit = sizeof(Unit) };
+ typedef void (quantity::*unspecified_null_pointer_constant_type)(int*******);
public:
typedef quantity<Unit,Y> this_type;
@@ -101,6 +102,11 @@
{
BOOST_UNITS_CHECK_LAYOUT_COMPATIBILITY(this_type, Y);
}
+
+ quantity(unspecified_null_pointer_constant_type) : val_()
+ {
+ BOOST_UNITS_CHECK_LAYOUT_COMPATIBILITY(this_type, Y);
+ }
quantity(const this_type& source) : val_(source.val_)
{
@@ -275,10 +281,10 @@
this_type& operator/=(const value_type& source) { val_ /= source; return *this; }
/// Construct quantity directly from @c value_type (potentially dangerous).
- static this_type from_value(const value_type& val) { return this_type(val); }
+ static this_type from_value(const value_type& val) { return this_type(val, 0); }
protected:
- explicit quantity(const value_type& val) : val_(val) { }
+ explicit quantity(const value_type& val, int) : val_(val) { }
private:
value_type val_;
Modified: branches/release/boost/units/scale.hpp
==============================================================================
--- branches/release/boost/units/scale.hpp (original)
+++ branches/release/boost/units/scale.hpp 2008-12-10 22:09:08 EST (Wed, 10 Dec 2008)
@@ -49,9 +49,9 @@
static const long base = Base;
typedef static_rational<0> exponent;
typedef one value_type;
- static one value() { return(one()); }
- static std::string name() { return(std::string()); }
- static std::string symbol() { return(std::string()); }
+ static one value() { one result; return(result); }
+ static std::string name() { return(""); }
+ static std::string symbol() { return(""); }
};
template<long Base>
Modified: branches/release/boost/units/static_rational.hpp
==============================================================================
--- branches/release/boost/units/static_rational.hpp (original)
+++ branches/release/boost/units/static_rational.hpp 2008-12-10 22:09:08 EST (Wed, 10 Dec 2008)
@@ -15,6 +15,12 @@
#include <boost/mpl/less.hpp>
#include <boost/mpl/arithmetic.hpp>
+#ifdef __BORLANDC__
+#include <boost/mpl/eval_if.hpp>
+#include <boost/mpl/integral_c.hpp>
+#include <boost/mpl/identity.hpp>
+#endif
+
#include <boost/units/config.hpp>
#include <boost/units/operators.hpp>
@@ -37,7 +43,7 @@
template<integer_type Value>
struct static_abs
{
- BOOST_STATIC_CONSTANT(integer_type,value) = Value < 0 ? -Value : Value;
+ BOOST_STATIC_CONSTANT(integer_type,value = Value < 0 ? -Value : Value);
};
/// Compile time rational number.
@@ -59,10 +65,68 @@
may not be floating point values, while powers and roots of rational numbers can produce floating point
values.
*/
+#ifdef __BORLANDC__
+
+template<integer_type X>
+struct make_integral_c {
+ typedef boost::mpl::integral_c<integer_type, X> type;
+};
+
+template<integer_type N,integer_type D = 1>
+class static_rational
+{
+ public:
+
+ typedef static_rational this_type;
+
+ typedef boost::mpl::integral_c<integer_type, N> N_type;
+ typedef boost::mpl::integral_c<integer_type, D> D_type;
+
+ typedef typename make_integral_c<
+ (::boost::math::static_gcd<
+ ::boost::units::static_abs<N>::value,
+ ::boost::units::static_abs<D>::value
+ >::value)>::type gcd_type;
+ typedef typename boost::mpl::eval_if<
+ boost::mpl::less<
+ D_type,
+ boost::mpl::integral_c<integer_type, 0>
+ >,
+ boost::mpl::negate<gcd_type>,
+ gcd_type
+ >::type den_type;
+
+ public:
+ // for mpl arithmetic support
+ typedef detail::static_rational_tag tag;
+
+ BOOST_STATIC_CONSTANT(integer_type, Numerator =
+ (::boost::mpl::divides<N_type, den_type>::value));
+ BOOST_STATIC_CONSTANT(integer_type, Denominator =
+ (::boost::mpl::divides<D_type, den_type>::value));
+
+ /// INTERNAL ONLY
+ typedef static_rational<N,D> this_type;
+
+ /// static_rational<N,D> reduced by GCD
+ typedef static_rational<
+ (::boost::mpl::divides<N_type, den_type>::value),
+ (::boost::mpl::divides<D_type, den_type>::value)
+ > type;
+
+ static integer_type numerator() { return Numerator; }
+ static integer_type denominator() { return Denominator; }
+
+ // INTERNAL ONLY
+ static_rational() { }
+ //~static_rational() { }
+};
+#else
template<integer_type N,integer_type D = 1>
class static_rational
{
private:
+
static const integer_type nabs = static_abs<N>::value,
dabs = static_abs<D>::value;
@@ -76,7 +140,7 @@
typedef detail::static_rational_tag tag;
static const integer_type Numerator = N/den,
- Denominator = D/den;
+ Denominator = D/den;
/// INTERNAL ONLY
typedef static_rational<N,D> this_type;
@@ -89,9 +153,9 @@
// INTERNAL ONLY
static_rational() { }
- //~static_rational() { }
-
+ //~static_rational() { }
};
+#endif
}
@@ -126,6 +190,86 @@
namespace mpl {
+#ifdef __BORLANDC__
+
+template<>
+struct plus_impl<boost::units::detail::static_rational_tag, boost::units::detail::static_rational_tag>
+{
+ template<class T0, class T1>
+ struct apply {
+ typedef typename boost::units::static_rational<
+ ::boost::mpl::plus<
+ boost::mpl::times<typename T0::N_type, typename T1::D_type>,
+ boost::mpl::times<typename T1::N_type, typename T0::D_type>
+ >::value,
+ ::boost::mpl::times<typename T0::D_type, typename T1::D_type>::value
+ >::type type;
+ };
+};
+
+template<>
+struct minus_impl<boost::units::detail::static_rational_tag, boost::units::detail::static_rational_tag>
+{
+ template<class T0, class T1>
+ struct apply {
+ typedef typename boost::units::static_rational<
+ ::boost::mpl::minus<
+ boost::mpl::times<typename T0::N_type, typename T1::D_type>,
+ boost::mpl::times<typename T1::N_type, typename T0::D_type>
+ >::value,
+ ::boost::mpl::times<typename T0::D_type, typename T1::D_type>::value
+ >::type type;
+ };
+};
+
+template<>
+struct times_impl<boost::units::detail::static_rational_tag, boost::units::detail::static_rational_tag>
+{
+ template<class T0, class T1>
+ struct apply {
+ typedef typename boost::units::static_rational<
+ ::boost::mpl::times<typename T0::N_type, typename T1::N_type>::value,
+ ::boost::mpl::times<typename T0::D_type, typename T1::D_type>::value
+ >::type type;
+ };
+};
+
+template<>
+struct divides_impl<boost::units::detail::static_rational_tag, boost::units::detail::static_rational_tag>
+{
+ template<class T0, class T1>
+ struct apply {
+ typedef typename boost::units::static_rational<
+ ::boost::mpl::times<typename T0::N_type, typename T1::D_type>::value,
+ ::boost::mpl::times<typename T0::D_type, typename T1::N_type>::value
+ >::type type;
+ };
+};
+
+template<>
+struct negate_impl<boost::units::detail::static_rational_tag>
+{
+ template<class T0>
+ struct apply {
+ typedef typename boost::units::static_rational<
+ ::boost::mpl::negate<typename T0::N_type>::value,
+ ::boost::mpl::identity<T0>::type::Denominator
+ >::type type;
+ };
+};
+
+template<>
+struct less_impl<boost::units::detail::static_rational_tag, boost::units::detail::static_rational_tag>
+{
+ template<class T0, class T1>
+ struct apply
+ {
+ typedef mpl::bool_<((mpl::minus<T0, T1>::type::Numerator) < 0)> type;
+ };
+};
+
+#else
+
template<>
struct plus_impl<boost::units::detail::static_rational_tag, boost::units::detail::static_rational_tag>
{
@@ -193,6 +337,8 @@
};
};
+#endif
+
}
Modified: branches/release/libs/units/doc/Jamfile.v2
==============================================================================
--- branches/release/libs/units/doc/Jamfile.v2 (original)
+++ branches/release/libs/units/doc/Jamfile.v2 2008-12-10 22:09:08 EST (Wed, 10 Dec 2008)
@@ -17,31 +17,30 @@
path-constant here : . ;
-rule run_doxygen ( target : files * : name : expand ? )
+rule run_doxygen ( target : files * : name )
{
-
- expand ?= <doxygen:param>EXPAND_ONLY_PREDEF=YES ;
-
-doxygen $(target)
- :
- $(files)
- :
+ doxygen $(target)
+ :
+ $(files)
+ :
<doxygen:param>EXTRACT_ALL=YES
+ <doxygen:param>EXPAND_ONLY_PREDEF=YES
-# Horribly ugly, but then macros usually are :(
- <doxygen:param>"PREDEFINED=\"BOOST_UNITS_STATIC_CONSTANT(a,b)=static const b a\" \\
- \"BOOST_UNITS_AUTO_STATIC_CONSTANT(a,b)=static const auto a = b\" \\
- \"BOOST_UNITS_TYPEOF(a)=typeof(a)\" \\
- \"BOOST_PREVENT_MACRO_SUBSTITUTION=\" \\
- \"BOOST_UNITS_HAS_TYPEOF=1\" \\
- \"BOOST_UNITS_DEFINE_BASE_UNIT_WITH_CONVERSIONS(namespace_, name_, name_string, symbol_, factor, other_unit, id)= \\
- namespace boost { namespace units { namespace namespace_ { \\
- struct name_ ## _base_unit : boost::units::base_unit<name_ ## _base_unit, other_unit::dimension_type, id> { \\
- static const char* name(); \\
- static const char* symbol(); \\
- }; \\
- } } }\" \\
- \"BOOST_UNITS_DOXYGEN=1\""
+ # Horribly ugly, but then macros usually are :(
+ <doxygen:param>"PREDEFINED= \\
+ \"BOOST_UNITS_STATIC_CONSTANT(a,b)=static const b a\" \\
+ \"BOOST_UNITS_AUTO_STATIC_CONSTANT(a,b)=static const auto a = b\" \\
+ \"BOOST_UNITS_TYPEOF(a)=typeof(a)\" \\
+ \"BOOST_PREVENT_MACRO_SUBSTITUTION=\" \\
+ \"BOOST_UNITS_HAS_TYPEOF=1\" \\
+ \"BOOST_UNITS_DEFINE_BASE_UNIT_WITH_CONVERSIONS(namespace_, name_, name_string, symbol_, factor, other_unit, id)= \\
+ namespace boost { namespace units { namespace namespace_ { \\
+ struct name_ ## _base_unit : boost::units::base_unit<name_ ## _base_unit, other_unit::dimension_type, id> { \\
+ static const char* name(); \\
+ static const char* symbol(); \\
+ }; \\
+ } } }\" \\
+ \"BOOST_UNITS_DOXYGEN=1\""
<doxygen:param>HIDE_UNDOC_MEMBERS=NO
<doxygen:param>EXTRACT_PRIVATE=NO
<doxygen:param>ENABLE_PREPROCESSING=YES
@@ -49,7 +48,7 @@
$(expand)
<doxygen:param>SEARCH_INCLUDES=NO
<reftitle>$(name)
- ;
+ ;
}
@@ -76,7 +75,8 @@
"CGS System Reference"
;
-rule make_base_units_doc ( directory : name ) {
+rule make_base_units_doc ( directory : name )
+{
run_doxygen $(directory)_base_units_reference
:
[ path.glob-tree $(here)/../../../boost/units/base_units/$(directory) : *.hpp : detail conversions.hpp ]
@@ -127,39 +127,48 @@
"Abstract System Reference"
;
-rule less ( a b ) {
- if [ path.basename $(a) ] < [ path.basename $(b) ] {
+rule less ( a b )
+{
+ if [ path.basename $(a) ] < [ path.basename $(b) ]
+ {
return true ;
}
}
-rule generate-qbk ( target : sources * : properties * ) {
+rule generate-qbk ( target : sources * : properties * )
+{
print.output $(target) ;
local as-path = [ sequence.transform path.make : $(sources:G=) ] ;
local known = ;
local duplicated = ;
- for local file in $(as-path) {
+ for local file in $(as-path)
+ {
local base = [ path.basename $(file) ] ;
- if $(base) in $(known) {
- if ! $(base) in $(duplicated) {
+ if $(base) in $(known)
+ {
+ if ! $(base) in $(duplicated)
+ {
duplicated += $(base) ;
}
- } else {
+ } else
+ {
known += $(base) ;
}
}
- for local file in [ sequence.insertion-sort $(as-path) : less ] {
+ for local file in [ sequence.insertion-sort $(as-path) : less ]
+ {
local output_filename = [ path.relative-to [ path.make $(here)/../../.. ] $(file) ] ;
local base_filename = [ path.basename $(file) ] ;
local base_unit = [ regex.replace $(base_filename) "\\.hpp" "" ] ;
- if $(base_filename) in $(duplicated) {
+ if $(base_filename) in $(duplicated)
+ {
# tack the directory name onto the end
local dir-name = [ path.basename [ path.parent $(file) ] ] ;
base_unit = "$(base_unit) ($(dir-name))" ;
}
-# this looks better, but it won't work until my boostbook patch for
-# annotation.xsl gets applied.
-# print.text "[headerref $(output_filename) $(base_unit)]\\n" : overwrite ;
+ # this looks better, but it won't work until my boostbook patch for
+ # annotation.xsl gets applied.
+ # print.text "[headerref $(output_filename) $(base_unit)]\\n" : overwrite ;
print.text "[headerref $(output_filename)]\\n" : overwrite ;
}
}
@@ -184,6 +193,8 @@
<dependency>abstract_reference
;
+path-constant images_location : ../../../doc/html ;
+
boostbook standalone
:
units
@@ -191,8 +202,31 @@
<xsl:param>toc.max.depth=1
<xsl:param>toc.section.depth=8
<xsl:param>chunk.section.depth=8
- <xsl:param>fop1.extensions=1
- <xsl:param>fop.extensions=0
<xsl:param>boost.root="../../../.."
<xsl:param>html.stylesheet=../../../../doc/html/boostbook.css
- ;
+
+ # PDF Options:
+ # TOC generation: uses XEP extensions at present, change to fop1 to use Apache FOP.
+ <format>pdf:<xsl:param>xep.extensions=1
+ <format>pdf:<xsl:param>fop.extensions=0
+ <format>pdf:<xsl:param>fop1.extensions=0
+ # No indent on body text:
+ <format>pdf:<xsl:param>body.start.indent=0pt
+ # Margin size:
+ <format>pdf:<xsl:param>page.margin.inner=0.5in
+ # Margin size:
+ <format>pdf:<xsl:param>page.margin.outer=0.5in
+ # Paper type = A4
+ <format>pdf:<xsl:param>paper.type=A4
+ # Yes, we want graphics for admonishments:
+ <xsl:param>admon.graphics=1
+ # Set this one for PDF generation *only*:
+ # default pnd graphics are awful in PDF form,
+ # better use SVG's instead:
+ <format>pdf:<xsl:param>admon.graphics.extension=".svg"
+ <format>pdf:<xsl:param>img.src.path=$(images_location)/
+ <format>pdf:<xsl:param>admon.graphics.path=../../../doc/src/images
+ <format>pdf:<xsl:param>draft.mode="no"
+;
+
+
Modified: branches/release/libs/units/example/Jamfile.v2
==============================================================================
--- branches/release/libs/units/example/Jamfile.v2 (original)
+++ branches/release/libs/units/example/Jamfile.v2 2008-12-10 22:09:08 EST (Wed, 10 Dec 2008)
@@ -1,32 +1,25 @@
# Jamfile.v2
#
-# Copyright (c) 2007
+# Copyright (c) 2007-2008
# Steven Watanabe
#
# Distributed under the Boost Software License, Version 1.0. (See
-# accomanying file LICENSE_1_0.txt or copy at
+# accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt
import testing ;
import path ;
-project units_examples :
+project boost/units/example :
: requirements <include>$(BOOST_ROOT) <include>../../.. <warnings>all
;
-rule make_tests ( files * ) {
- local results = ;
- for local file in $(files) {
- results += [ run $(file) : : : ] ;
- }
-}
+files = [ path.glob . : *.cpp : performance.* runtime_unit.* ] ;
+for local file in $(files)
{
- test-suite units
- :
- [ make_tests [ path.glob . : *.cpp : performance.* runtime_unit.* ] ]
- [ compile performance.cpp ]
- [ run runtime_unit.cpp : <runtime_unit_input.txt : : ]
- ;
-
+ run $(file) ;
}
+
+compile performance.cpp ;
+run runtime_unit.cpp : <runtime_unit_input.txt ;
Modified: branches/release/libs/units/test/Jamfile.v2
==============================================================================
--- branches/release/libs/units/test/Jamfile.v2 (original)
+++ branches/release/libs/units/test/Jamfile.v2 2008-12-10 22:09:08 EST (Wed, 10 Dec 2008)
@@ -4,69 +4,58 @@
# Steven Watanabe
#
# Distributed under the Boost Software License, Version 1.0. (See
-# accomanying file LICENSE_1_0.txt or copy at
+# accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt
-project units_test :
+project boost/units/test :
requirements <include>$(BOOST_ROOT) <include>../../.. <toolset>msvc:<asynch-exceptions>on
;
-check-conversion-dependencies = [ path.glob-tree ../../../boost/units/systems/base_units : *.hpp ] ;
-checklibs =
- $(BOOST_ROOT)/libs/regex/build//boost_regex
- $(BOOST_ROOT)/libs/filesystem/build//boost_filesystem
- $(BOOST_ROOT)/libs/system/build//boost_system
-;
-
import testing ;
alias test_framework : $(BOOST_ROOT)/libs/test/build//boost_unit_test_framework ;
-#alias test_minimal : $(BOOST_ROOT)/libs/test/build//minimal ;
-
-{
- test-suite units
- :
- [ compile test_predicates.cpp : : ]
- [ compile test_negative_denominator.cpp : : ]
- [ compile test_dimensionless_ice1.cpp : : ]
- [ compile test_dimensionless_ice2.cpp : : ]
- [ compile test_mixed_value_types.cpp : : ]
- [ compile test_complicated_system.cpp : : ]
- [ run test_dimensionless_quantity.cpp : : : : ]
- [ run test_implicit_conversion.cpp : : : : ]
- [ run test_quantity.cpp : : : : ]
- [ run test_unit.cpp : : : : ]
- [ run test_conversion.cpp : : : : ]
- [ run test_base_dimension.cpp : : : : ]
- [ run test_absolute.cpp : : : : ]
- [ run test_default_conversion.cpp : : : : ]
- [ run test_cmath.cpp : : : : ]
- [ run test_limits.cpp : : : : ]
- [ run test_custom_unit.cpp : : : : ]
- [ run test_scaled_conversion.cpp : : : : ]
- [ run test_lambda.cpp : : : : ]
- [ run test_scaled_unit.cpp test_framework : : : : ]
-# [ run check_conversion_defs.cpp $(checklibs) : : : <dependency>$(check-conversion-dependencies) : ]
- [ compile-fail fail_implicit_conversion.cpp : : ]
- [ compile-fail fail_quantity_construct.cpp : : ]
- [ compile-fail fail_quantity_assign.cpp : : ]
- [ compile-fail fail_quantity_add.cpp : : ]
- [ compile-fail fail_quantity_subtract.cpp : : ]
- [ compile-fail fail_quantity_add_assign.cpp : : ]
- [ compile-fail fail_quantity_sub_assign.cpp : : ]
- [ compile-fail fail_quantity_scalar_add.cpp : : ]
- [ compile-fail fail_quantity_scalar_sub.cpp : : ]
- [ compile-fail fail_quantity_unit_add.cpp : : ]
- [ compile-fail fail_quantity_unit_subtract.cpp : : ]
- [ compile-fail fail_scalar_quantity_add.cpp : : ]
- [ compile-fail fail_scalar_quantity_sub.cpp : : ]
- [ compile-fail fail_unit_quantity_add.cpp : : ]
- [ compile-fail fail_unit_quantity_subtract.cpp : : ]
- [ compile-fail fail_adl_detail.cpp : : ]
- [ compile-fail fail_heterogeneous_unit.cpp : : ]
- [ compile-fail fail_base_dimension.cpp : : ]
- [ compile-fail fail_add_temperature.cpp : : ]
- [ compile-fail fail_quantity_non_unit.cpp : : ]
- ;
-}
+compile test_predicates.cpp ;
+compile test_negative_denominator.cpp ;
+compile test_dimensionless_ice1.cpp ;
+compile test_dimensionless_ice2.cpp ;
+compile test_mixed_value_types.cpp ;
+compile test_complicated_system.cpp ;
+compile test_reduce_unit.cpp ;
+compile test_unscale.cpp ;
+
+run test_dimensionless_quantity.cpp ;
+run test_implicit_conversion.cpp ;
+run test_quantity.cpp ;
+run test_unit.cpp ;
+run test_conversion.cpp test_framework ;
+run test_base_dimension.cpp ;
+run test_absolute.cpp ;
+run test_default_conversion.cpp ;
+run test_cmath.cpp ;
+run test_limits.cpp ;
+run test_custom_unit.cpp ;
+run test_scaled_conversion.cpp ;
+run test_lambda.cpp ;
+run test_scaled_unit.cpp test_framework ;
+
+compile-fail fail_implicit_conversion.cpp ;
+compile-fail fail_quantity_construct.cpp ;
+compile-fail fail_quantity_assign.cpp ;
+compile-fail fail_quantity_add.cpp ;
+compile-fail fail_quantity_subtract.cpp ;
+compile-fail fail_quantity_add_assign.cpp ;
+compile-fail fail_quantity_sub_assign.cpp ;
+compile-fail fail_quantity_scalar_add.cpp ;
+compile-fail fail_quantity_scalar_sub.cpp ;
+compile-fail fail_quantity_unit_add.cpp ;
+compile-fail fail_quantity_unit_subtract.cpp ;
+compile-fail fail_scalar_quantity_add.cpp ;
+compile-fail fail_scalar_quantity_sub.cpp ;
+compile-fail fail_unit_quantity_add.cpp ;
+compile-fail fail_unit_quantity_subtract.cpp ;
+compile-fail fail_adl_detail.cpp ;
+compile-fail fail_heterogeneous_unit.cpp ;
+compile-fail fail_base_dimension.cpp ;
+compile-fail fail_add_temperature.cpp ;
+compile-fail fail_quantity_non_unit.cpp ;
Modified: branches/release/libs/units/test/test_cmath.cpp
==============================================================================
--- branches/release/libs/units/test/test_cmath.cpp (original)
+++ branches/release/libs/units/test/test_cmath.cpp 2008-12-10 22:09:08 EST (Wed, 10 Dec 2008)
@@ -129,19 +129,14 @@
#endif
-#if 0
-
BOOST_CHECK((bu::nextafter)(E4,E5).value() == (boost::math::nextafter)(E4.value(),E5.value()));
BOOST_CHECK((bu::nextafter)(E5,E4).value() == (boost::math::nextafter)(E5.value(),E4.value()));
BOOST_CHECK((bu::nexttoward)(E4,E5).value() == (boost::math::nextafter)(E4.value(),E5.value()));
BOOST_CHECK((bu::nexttoward)(E5,E4).value() == (boost::math::nextafter)(E5.value(),E4.value()));
-
BOOST_CHECK((bu::round)(E4 - 0.00000000001 * bu::joules) == -3.0*bu::joules);
BOOST_CHECK((bu::round)(E5 + 0.00000000001 * bu::joules) == 3.0*bu::joules);
-#endif
-
BOOST_CHECK((bu::signbit)(E4) == 1);
BOOST_CHECK((bu::signbit)(E5) == 0);
BOOST_CHECK((bu::trunc)(E4) == -2.0*bu::joules);
Modified: branches/release/libs/units/test/test_conversion.cpp
==============================================================================
--- branches/release/libs/units/test/test_conversion.cpp (original)
+++ branches/release/libs/units/test/test_conversion.cpp 2008-12-10 22:09:08 EST (Wed, 10 Dec 2008)
@@ -27,9 +27,11 @@
#include <iostream>
-#include <boost/test/minimal.hpp>
+#define BOOST_TEST_MAIN
-#define BOOST_UNITS_CHECK_CLOSE(a, b) (BOOST_CHECK((std::abs((a) - (b)) < .0000001)))
+#include <boost/test/unit_test.hpp>
+
+#define BOOST_UNITS_CHECK_CLOSE(a, b) BOOST_CHECK_CLOSE_FRACTION(a, b, .0000001)
namespace bu = boost::units;
@@ -50,35 +52,39 @@
typedef bu::divide_typeof_helper<bu::multiply_typeof_helper<cgs_mass,mixed_length>::type,
bu::multiply_typeof_helper<cgs_time,cgs_time>::type >::type mixed_energy_2;
-int test_main(int,char *[])
-{
+BOOST_AUTO_TEST_CASE(test_conversion) {
+ BOOST_CHECK_EQUAL(1, 1);
bu::quantity<mixed_length> a1(2.0 * mixed_length());
bu::quantity<si_area> a2(a1);
- BOOST_CHECK((std::abs(a2.value() - .02) < .0001));
+ BOOST_UNITS_CHECK_CLOSE(a2.value(), .02);
bu::quantity<mixed_length> a3(a2);
- BOOST_CHECK((std::abs(a3.value() - 2.0) < .0001));
+ BOOST_UNITS_CHECK_CLOSE(a3.value(), 2.0);
bu::quantity<mixed_energy_1> e1(2.0 * mixed_energy_1());
bu::quantity<mixed_energy_2> e2(e1);
- BOOST_CHECK((std::abs(e2.value() - 20.0) < .0001));
+ BOOST_UNITS_CHECK_CLOSE(e2.value(), 20.0);
bu::quantity<bu::si::energy> e3(e1);
- BOOST_CHECK((std::abs(e3.value() - .0002) < .0001));
+ BOOST_UNITS_CHECK_CLOSE(e3.value(), .0002);
bu::quantity<mixed_energy_2> e4(e3);
- BOOST_CHECK((std::abs(e4.value() - 20.0) < .0001));
+ BOOST_UNITS_CHECK_CLOSE(e4.value(), 20.0);
bu::quantity<bu::cgs::force> F0 = 20 * bu::cgs::dyne;
- BOOST_CHECK((std::abs(F0.value() - 20.0) < .0001));
+ BOOST_UNITS_CHECK_CLOSE(F0.value(), 20.0);
bu::quantity<bu::si::force> F3(F0);
- BOOST_CHECK((std::abs(F3.value() - 2.0e-4) < .000000001));
+ BOOST_UNITS_CHECK_CLOSE(F3.value(), 2.0e-4);
bu::quantity<bu::si::force> F5(20 * bu::cgs::dyne);
- BOOST_CHECK((std::abs(F5.value() - 2.0e-4) < .000000001));
+ BOOST_UNITS_CHECK_CLOSE(F5.value(), 2.0e-4);
+
+}
+
+BOOST_AUTO_TEST_CASE(test_dimensionless_conversions) {
bu::quantity<bu::si::dimensionless> dimensionless_test1(1.0*bu::cgs::dyne/bu::si::newton);
BOOST_CHECK(dimensionless_test1 == 1e-5);
@@ -94,6 +100,4 @@
bu::quantity<bu::divide_typeof_helper<bu::si::length, bu::cgs::length>::type> dimensionless_test4(2.0 * bu::si::meters / bu::cgs::centimeters);
bu::quantity<bu::divide_typeof_helper<bu::cgs::mass, bu::si::mass>::type> dimensionless_test5(dimensionless_test4);
BOOST_UNITS_CHECK_CLOSE(dimensionless_test5.value(), 2e5);
-
- return(0);
}
Modified: branches/release/libs/units/test/test_lambda.cpp
==============================================================================
--- branches/release/libs/units/test/test_lambda.cpp (original)
+++ branches/release/libs/units/test/test_lambda.cpp 2008-12-10 22:09:08 EST (Wed, 10 Dec 2008)
@@ -142,9 +142,21 @@
// quantity<Unit1, X> + quantity<Unit2, Y>
BOOST_CHECK(((bl::_1 + bl::_2)(2.0 * bu::meter, 4.0 * bu::meter) == 6.0 * bu::meter));
+ // quantity<dimensionless, X> + Y
+ BOOST_CHECK(((bl::_1 + 1.0f)(bu::quantity<bu::dimensionless>(2.0)) == 3.0));
+
+ // X + quantity<dimensionless, Y>
+ BOOST_CHECK(((1.0f + bl::_1)(bu::quantity<bu::dimensionless>(1.0)) == 2.0));
+
// quantity<Unit1, X> - quantity<Unit2, Y>
BOOST_CHECK(((bl::_1 - bl::_2)(2.0 * bu::meter, 4.0 * bu::meter) == -2.0 * bu::meter));
+ // quantity<dimensionless, X> - Y
+ BOOST_CHECK(((bl::_1 - 2.0f)(bu::quantity<bu::dimensionless>(1.0)) == -1.0));
+
+ // X - quantity<dimensionless, Y>
+ BOOST_CHECK(((2.0f - bl::_1)(bu::quantity<bu::dimensionless>(1.0)) == 1.0));
+
// quantity<Unit1, X> * quantity<Unit2, Y>
BOOST_CHECK(((bl::_1 * bl::_2)(2.0 * bu::kilogram, 4.0 * bu::meter_per_second) == 8.0 * bu::kilogram * bu::meter_per_second));
Modified: branches/release/libs/units/test_headers/Jamfile.v2
==============================================================================
--- branches/release/libs/units/test_headers/Jamfile.v2 (original)
+++ branches/release/libs/units/test_headers/Jamfile.v2 2008-12-10 22:09:08 EST (Wed, 10 Dec 2008)
@@ -4,40 +4,45 @@
# Steven Watanabe
#
# Distributed under the Boost Software License, Version 1.0. (See
-# accomanying file LICENSE_1_0.txt or copy at
+# accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt
import testing ;
import path ;
import regex ;
import print ;
+import sequence ;
+import feature ;
-project test_headers :
+project boost/units/test_headers :
requirements <include>$(BOOST_ROOT) <include>../../..
;
headers = [ path.glob-tree ../../../boost/units : *.hpp : detail ] ;
-rule setup ( ) {
- for local file in $(headers) {
-
- result += [ compile test.cpp :
- <define>BOOST_UNITS_HEADER_NAME=$(file)
- <dependency>$(file)
- :
- [ regex.replace [ path.relative-to ../../.. $(file) ] "/" "_" ] ] ;
-
- }
- return $(result) ;
+for local file in $(headers)
+{
+ compile test.cpp
+ : # requirements
+ <define>BOOST_UNITS_HEADER_NAME=$(file)
+ <dependency>$(file)
+ : # test name
+ [ regex.replace [ path.relative-to ../../.. $(file) ] "/" "_" ] ;
}
-tests = [ setup ] ;
-
-rule generate-include-all ( target : sources * : properties * ) {
+feature.feature <generate-include-all-order> : forward reverse : incidental ;
+rule generate-include-all ( target : sources * : properties * )
+{
print.output $(target) ;
- for local file in $(sources) {
+ if <generate-include-all-order>reverse in $(properties)
+ {
+ sources = [ sequence.reverse $(sources) ] ;
+ }
+
+ for local file in $(sources)
+ {
print.text "#include <$(file:G=)>
" : overwrite ;
}
@@ -45,12 +50,7 @@
}
make include_all1.cpp : $(headers) : @generate-include-all ;
-make include_all2.cpp : $(headers) : @generate-include-all ;
-
-import testing ;
+make include_all2.cpp : $(headers) : @generate-include-all : <generate-include-all-order>reverse ;
-test-suite units_headers :
- $(tests)
# this ought to catch non-inlined functions and other duplicate definitions
- [ link include_all1.cpp include_all2.cpp main.cpp : <include>. : include_all_headers ]
- ;
+link include_all1.cpp include_all2.cpp main.cpp : <include>. : include_all_headers ;
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk