Boost logo

Boost-Commit :

From: steven_at_[hidden]
Date: 2008-05-30 00:41:02


Author: steven_watanabe
Date: 2008-05-30 00:41:01 EDT (Fri, 30 May 2008)
New Revision: 45932
URL: http://svn.boost.org/trac/boost/changeset/45932

Log:
The problem I discovered on tuesday turns out to be a problem in my test case rather than the library. Added static assertions to catch such errors earlier
Text files modified:
   sandbox/units/boost/units/detail/linear_algebra.hpp | 4 ++++
   sandbox/units/boost/units/heterogeneous_system.hpp | 3 +++
   sandbox/units/libs/units/test/test_complicated_system.cpp | 9 +++++++--
   3 files changed, 14 insertions(+), 2 deletions(-)

Modified: sandbox/units/boost/units/detail/linear_algebra.hpp
==============================================================================
--- sandbox/units/boost/units/detail/linear_algebra.hpp (original)
+++ sandbox/units/boost/units/detail/linear_algebra.hpp 2008-05-30 00:41:01 EDT (Fri, 30 May 2008)
@@ -29,6 +29,7 @@
 #include <boost/mpl/erase.hpp>
 #include <boost/mpl/front.hpp>
 #include <boost/mpl/and.hpp>
+#include <boost/mpl/assert.hpp>
 
 #include <boost/units/dim.hpp>
 #include <boost/units/dimensionless_type.hpp>
@@ -636,6 +637,9 @@
 
 template<int N>
 struct add_zeroes_impl {
+ // If you get an error here and your base units are
+ // in fact linearly independent, please report it.
+ BOOST_MPL_ASSERT_MSG((N > 0), base_units_are_probably_not_linearly_independent, (void));
     template<class T>
     struct apply {
         typedef typename mpl::push_front<

Modified: sandbox/units/boost/units/heterogeneous_system.hpp
==============================================================================
--- sandbox/units/boost/units/heterogeneous_system.hpp (original)
+++ sandbox/units/boost/units/heterogeneous_system.hpp 2008-05-30 00:41:01 EDT (Fri, 30 May 2008)
@@ -24,6 +24,8 @@
 #include <boost/mpl/front.hpp>
 #include <boost/mpl/push_front.hpp>
 #include <boost/mpl/pop_front.hpp>
+#include <boost/mpl/assert.hpp>
+#include <boost/type_traits/is_same.hpp>
 
 #include <boost/units/config.hpp>
 #include <boost/units/static_rational.hpp>
@@ -236,6 +238,7 @@
 struct make_heterogeneous_system
 {
     typedef typename calculate_base_unit_exponents<typename System::type, Dimensions>::type exponents;
+ BOOST_MPL_ASSERT_MSG((!boost::is_same<exponents, inconsistent>::value), the_specified_dimension_is_not_representible_in_the_given_system, (types<Dimensions, System>));
     typedef typename make_heterogeneous_system_impl<mpl::size<typename System::type>::value>::template apply<
         typename mpl::begin<typename System::type>::type,
         typename mpl::begin<exponents>::type

Modified: sandbox/units/libs/units/test/test_complicated_system.cpp
==============================================================================
--- sandbox/units/libs/units/test/test_complicated_system.cpp (original)
+++ sandbox/units/libs/units/test/test_complicated_system.cpp 2008-05-30 00:41:01 EDT (Fri, 30 May 2008)
@@ -8,6 +8,11 @@
 // accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
 
+template<class T>
+struct print {
+ enum { value = false };
+};
+
 #include <boost/type_traits/is_same.hpp>
 #include <boost/mpl/assert.hpp>
 
@@ -35,14 +40,14 @@
 
 struct volt : boost::units::base_unit<volt, boost::units::electric_potential_dimension, 1> {};
 struct newton : boost::units::base_unit<newton, boost::units::force_dimension, 2> {};
-struct joule : boost::units::base_unit<joule, boost::units::electric_potential_dimension, 3> {};
+struct joule : boost::units::base_unit<joule, boost::units::energy_dimension, 3> {};
 
 typedef boost::units::make_system<volt, newton, joule>::type complicated_system;
 
 typedef boost::units::derived_dimension<
     boost::units::length_base_dimension, -1,
     boost::units::time_base_dimension, -1,
- boost::units::current_base_dimension, 1
+ boost::units::current_base_dimension, -1
>::type dimension;
 
 typedef boost::units::reduce_unit<boost::units::unit<dimension, complicated_system> >::type reduced;


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