Boost logo

Boost-Commit :

From: steven_at_[hidden]
Date: 2008-05-14 23:34:15


Author: steven_watanabe
Date: 2008-05-14 23:34:14 EDT (Wed, 14 May 2008)
New Revision: 45380
URL: http://svn.boost.org/trac/boost/changeset/45380

Log:
Made dimension_list.hpp private
Added:
   sandbox/units/boost/units/detail/dimension_list.hpp
      - copied unchanged from r45377, /sandbox/units/boost/units/dimension_list.hpp
Removed:
   sandbox/units/boost/units/dimension_list.hpp
Text files modified:
   sandbox/units/boost/units/base_dimension.hpp | 3 -
   sandbox/units/boost/units/base_unit.hpp | 3 -
   sandbox/units/boost/units/derived_dimension.hpp | 2
   sandbox/units/boost/units/detail/conversion_impl.hpp | 2
   sandbox/units/boost/units/detail/dimension_impl.hpp | 2
   sandbox/units/boost/units/detail/linear_algebra.hpp | 2
   sandbox/units/boost/units/detail/sort.hpp | 2
   sandbox/units/boost/units/dimension.hpp | 50 +++++++++++++++++++++------------------
   sandbox/units/boost/units/dimensionless_type.hpp | 45 ++++++++++++++++++++++++++++++++++-
   sandbox/units/boost/units/make_system.hpp | 2
   10 files changed, 78 insertions(+), 35 deletions(-)

Modified: sandbox/units/boost/units/base_dimension.hpp
==============================================================================
--- sandbox/units/boost/units/base_dimension.hpp (original)
+++ sandbox/units/boost/units/base_dimension.hpp 2008-05-14 23:34:14 EDT (Wed, 14 May 2008)
@@ -13,10 +13,9 @@
 
 #include <boost/units/config.hpp>
 #include <boost/units/dim.hpp>
-#include <boost/units/dimension_list.hpp>
 #include <boost/units/static_rational.hpp>
 #include <boost/units/units_fwd.hpp>
-
+#include <boost/units/detail/dimension_list.hpp>
 #include <boost/units/detail/prevent_redefinition.hpp>
 
 namespace boost {

Modified: sandbox/units/boost/units/base_unit.hpp
==============================================================================
--- sandbox/units/boost/units/base_unit.hpp (original)
+++ sandbox/units/boost/units/base_unit.hpp 2008-05-14 23:34:14 EDT (Wed, 14 May 2008)
@@ -12,12 +12,11 @@
 #define BOOST_UNITS_BASE_UNIT_HPP
 
 #include <boost/units/config.hpp>
-#include <boost/units/dimension_list.hpp>
 #include <boost/units/heterogeneous_system.hpp>
 #include <boost/units/static_rational.hpp>
 #include <boost/units/units_fwd.hpp>
 #include <boost/units/unit.hpp>
-
+#include <boost/units/detail/dimension_list.hpp>
 #include <boost/units/detail/prevent_redefinition.hpp>
 
 namespace boost {

Modified: sandbox/units/boost/units/derived_dimension.hpp
==============================================================================
--- sandbox/units/boost/units/derived_dimension.hpp (original)
+++ sandbox/units/boost/units/derived_dimension.hpp 2008-05-14 23:34:14 EDT (Wed, 14 May 2008)
@@ -15,9 +15,9 @@
 
 #include <boost/units/dim.hpp>
 #include <boost/units/dimension.hpp>
-#include <boost/units/dimension_list.hpp>
 #include <boost/units/static_rational.hpp>
 #include <boost/units/units_fwd.hpp>
+#include <boost/units/detail/dimension_list.hpp>
 
 namespace boost {
 

Modified: sandbox/units/boost/units/detail/conversion_impl.hpp
==============================================================================
--- sandbox/units/boost/units/detail/conversion_impl.hpp (original)
+++ sandbox/units/boost/units/detail/conversion_impl.hpp 2008-05-14 23:34:14 EDT (Wed, 14 May 2008)
@@ -21,13 +21,13 @@
 #include <boost/type_traits/is_same.hpp>
 #include <boost/type_traits/is_base_and_derived.hpp>
 
-#include <boost/units/dimension_list.hpp>
 #include <boost/units/heterogeneous_system.hpp>
 #include <boost/units/homogeneous_system.hpp>
 #include <boost/units/reduce_unit.hpp>
 #include <boost/units/scale.hpp>
 #include <boost/units/static_rational.hpp>
 #include <boost/units/units_fwd.hpp>
+#include <boost/units/detail/dimension_list.hpp>
 #include <boost/units/detail/heterogeneous_conversion.hpp>
 #include <boost/units/detail/one.hpp>
 #include <boost/units/detail/static_rational_power.hpp>

Modified: sandbox/units/boost/units/detail/dimension_impl.hpp
==============================================================================
--- sandbox/units/boost/units/detail/dimension_impl.hpp (original)
+++ sandbox/units/boost/units/detail/dimension_impl.hpp 2008-05-14 23:34:14 EDT (Wed, 14 May 2008)
@@ -21,10 +21,10 @@
 #include <boost/mpl/less.hpp>
 
 #include <boost/units/config.hpp>
-#include <boost/units/dimension_list.hpp>
 #include <boost/units/dimensionless_type.hpp>
 #include <boost/units/static_rational.hpp>
 #include <boost/units/units_fwd.hpp>
+#include <boost/units/detail/dimension_list.hpp>
 #include <boost/units/detail/push_front_if.hpp>
 #include <boost/units/detail/push_front_or_add.hpp>
 

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-14 23:34:14 EDT (Wed, 14 May 2008)
@@ -31,9 +31,9 @@
 #include <boost/mpl/and.hpp>
 
 #include <boost/units/dim.hpp>
-#include <boost/units/dimension_list.hpp>
 #include <boost/units/dimensionless_type.hpp>
 #include <boost/units/static_rational.hpp>
+#include <boost/units/detail/dimension_list.hpp>
 #include <boost/units/detail/sort.hpp>
 
 namespace boost {

Modified: sandbox/units/boost/units/detail/sort.hpp
==============================================================================
--- sandbox/units/boost/units/detail/sort.hpp (original)
+++ sandbox/units/boost/units/detail/sort.hpp 2008-05-14 23:34:14 EDT (Wed, 14 May 2008)
@@ -18,8 +18,8 @@
 #include <boost/mpl/push_front.hpp>
 #include <boost/mpl/less.hpp>
 
-#include <boost/units/dimension_list.hpp>
 #include <boost/units/dimensionless_type.hpp>
+#include <boost/units/detail/dimension_list.hpp>
 
 namespace boost {
 

Modified: sandbox/units/boost/units/dimension.hpp
==============================================================================
--- sandbox/units/boost/units/dimension.hpp (original)
+++ sandbox/units/boost/units/dimension.hpp 2008-05-14 23:34:14 EDT (Wed, 14 May 2008)
@@ -20,9 +20,9 @@
 #include <boost/mpl/size.hpp>
 
 #include <boost/units/dim.hpp>
-#include <boost/units/dimension_list.hpp>
 #include <boost/units/operators.hpp>
 #include <boost/units/static_rational.hpp>
+#include <boost/units/detail/dimension_list.hpp>
 #include <boost/units/detail/dimension_impl.hpp>
 
 /// \file
@@ -32,10 +32,30 @@
 
 namespace units {
 
-/// Reduce dimension list to cardinal form. This algorithm collapses duplicate unit
-/// tags and sorts the resulting list by the tag ordinal value.
+struct S;
+
+/// Reduce dimension list to cardinal form. This algorithm collapses duplicate
+/// base dimension tags and sorts the resulting list by the tag ordinal value.
 /// Dimension lists that resolve to the same dimension are guaranteed to be
 /// represented by an identical type.
+///
+/// The argument should be an MPL forward sequence containing instances
+/// of the @c dim template.
+///
+/// The result is also an MPL forward sequence. It also supports the
+/// following metafunctions to allow use as a dimension.
+///
+/// - @c mpl::plus is defined only on two equal dimensions and returns the argument unchanged.
+/// - @c mpl::minus is defined only for two equal dimensions and returns the argument unchanged.
+/// - @c mpl::negate will return its argument unchanged.
+/// - @c mpl::times is defined for any dimensions and adds corresponding exponents.
+/// - @c mpl::divides is defined for any dimensions and subtracts the exponents of the
+/// right had argument from the corresponding exponents of the left had argument.
+/// Missing base dimension tags are assumed to have an exponent of zero.
+/// - @c static_power takes a dimension and a static_rational and multiplies all
+/// the exponents of the dimension by the static_rational.
+/// - @c static_root takes a dimension and a static_rational and divides all
+/// the exponents of the dimension by the static_rational.
 template<typename Seq>
 struct make_dimension_list
 {
@@ -52,16 +72,6 @@
>::type type;
 };
 
-/// @c static_power specialized to a @c static_rational exponent.
-template<typename DL,long N,long D>
-struct static_power< DL,static_rational<N,D> >
-{
- typedef typename detail::static_power_impl<mpl::size<DL>::value>::template apply<
- typename mpl::begin<DL>::type,
- static_rational<N,D>
- >::type type;
-};
-
 /// Take a scalar root of a dimension list.
 template<typename DL,typename Rt>
 struct static_root
@@ -72,18 +82,10 @@
>::type type;
 };
 
-/// @c static_root specialized to a @c static_rational root.
-template<typename DL,long N,long D>
-struct static_root< DL,static_rational<N,D> >
-{
- typedef typename detail::static_root_impl<mpl::size<DL>::value>::template apply<
- typename mpl::begin<DL>::type,
- static_rational<N,D>
- >::type type;
-};
-
 } // namespace units
 
+#ifndef BOOST_UNITS_DOXYGEN
+
 namespace mpl {
 
 template<>
@@ -147,6 +149,8 @@
 
 } // namespace mpl
 
+#endif
+
 } // namespace boost
 
 #endif // BOOST_UNITS_DIMENSION_HPP

Deleted: sandbox/units/boost/units/dimension_list.hpp
==============================================================================
--- sandbox/units/boost/units/dimension_list.hpp 2008-05-14 23:34:14 EDT (Wed, 14 May 2008)
+++ (empty file)
@@ -1,133 +0,0 @@
-// mcs::units - A C++ library for zero-overhead dimensional analysis and
-// unit/quantity manipulation and conversion
-//
-// Copyright (C) 2003-2007 Matthias Christian Schabel
-// Copyright (C) 2007 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_DIMENSION_LIST_HPP
-#define BOOST_UNITS_DIMENSION_LIST_HPP
-
-#include <boost/mpl/next.hpp>
-#include <boost/mpl/deref.hpp>
-#include <boost/mpl/push_front_fwd.hpp>
-#include <boost/mpl/pop_front_fwd.hpp>
-#include <boost/mpl/size_fwd.hpp>
-#include <boost/mpl/begin_end_fwd.hpp>
-#include <boost/mpl/front_fwd.hpp>
-
-#include <boost/units/config.hpp>
-
-namespace boost {
-
-namespace units {
-
-struct dimensionless_type;
-
-namespace detail {
-
-struct dimension_list_tag { };
-
-} // namespace detail
-
-template<class Item, class Next>
-struct dimension_list
-{
- typedef detail::dimension_list_tag tag;
- typedef dimension_list type;
- typedef Item item;
- typedef Next next;
- typedef typename mpl::next<typename Next::size>::type size;
-};
-
-} // namespace units
-
-namespace mpl {
-
-// INTERNAL ONLY
-template<>
-struct size_impl<units::detail::dimension_list_tag>
-{
- template<class L> struct apply : public L::size { };
-};
-
-// INTERNAL ONLY
-template<>
-struct begin_impl<units::detail::dimension_list_tag>
-{
- template<class L>
- struct apply
- {
- typedef L type;
- };
-};
-
-// INTERNAL ONLY
-template<>
-struct end_impl<units::detail::dimension_list_tag>
-{
- template<class L>
- struct apply
- {
- typedef units::dimensionless_type type;
- };
-};
-
-// INTERNAL ONLY
-template<>
-struct push_front_impl<units::detail::dimension_list_tag>
-{
- template<class L, class T>
- struct apply
- {
- typedef units::dimension_list<T, L> type;
- };
-};
-
-// INTERNAL ONLY
-template<>
-struct pop_front_impl<units::detail::dimension_list_tag>
-{
- template<class L>
- struct apply
- {
- typedef typename L::next type;
- };
-};
-
-// INTERNAL ONLY
-template<>
-struct front_impl<units::detail::dimension_list_tag>
-{
- template<class L>
- struct apply
- {
- typedef typename L::item type;
- };
-};
-
-// INTERNAL ONLY
-template<class Item, class Next>
-struct deref<units::dimension_list<Item, Next> >
-{
- typedef Item type;
-};
-
-} // namespace mpl
-
-} // namespace boost
-
-#if BOOST_UNITS_HAS_BOOST_TYPEOF
-
-#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
-
-BOOST_TYPEOF_REGISTER_TEMPLATE(boost::units::dimension_list, 2)
-
-#endif
-
-#include <boost/units/dimensionless_type.hpp>
-
-#endif // BOOST_UNITS_DIMENSION_LIST_HPP

Modified: sandbox/units/boost/units/dimensionless_type.hpp
==============================================================================
--- sandbox/units/boost/units/dimensionless_type.hpp (original)
+++ sandbox/units/boost/units/dimensionless_type.hpp 2008-05-14 23:34:14 EDT (Wed, 14 May 2008)
@@ -13,14 +13,20 @@
 
 #include <boost/mpl/long.hpp>
 #include <boost/mpl/deref.hpp>
+#include <boost/mpl/arithmetic.hpp>
 
 #include <boost/units/config.hpp>
-#include <boost/units/dimension_list.hpp>
 
 namespace boost {
 
 namespace units {
 
+namespace detail {
+
+struct dimension_list_tag;
+
+}
+
 /// Dimension lists in which all exponents resolve to zero reduce to @c dimensionless_type.
 struct dimensionless_type
 {
@@ -35,9 +41,44 @@
 
 namespace mpl {
 
-// INTERNAL ONLY
+/// INTERNAL ONLY
 template<> struct deref<units::dimensionless_type> { };
 
+/// INTERNAL ONLY
+template<>
+struct plus<units::dimensionless_type, units::dimensionless_type>
+{
+ typedef units::dimensionless_type type;
+};
+
+/// INTERNAL ONLY
+template<>
+struct minus<units::dimensionless_type, units::dimensionless_type>
+{
+ typedef units::dimensionless_type type;
+};
+
+/// INTERNAL ONLY
+template<>
+struct times<units::dimensionless_type, units::dimensionless_type>
+{
+ typedef units::dimensionless_type type;
+};
+
+/// INTERNAL ONLY
+template<>
+struct divides<units::dimensionless_type, units::dimensionless_type>
+{
+ typedef units::dimensionless_type type;
+};
+
+/// INTERNAL ONLY
+template<>
+struct negate<units::dimensionless_type>
+{
+ typedef units::dimensionless_type type;
+};
+
 } // namespace mpl
 
 #endif

Modified: sandbox/units/boost/units/make_system.hpp
==============================================================================
--- sandbox/units/boost/units/make_system.hpp (original)
+++ sandbox/units/boost/units/make_system.hpp 2008-05-14 23:34:14 EDT (Wed, 14 May 2008)
@@ -15,8 +15,8 @@
 
 #include <boost/units/config.hpp>
 #include <boost/units/dimensionless_type.hpp>
-#include <boost/units/dimension_list.hpp>
 #include <boost/units/homogeneous_system.hpp>
+#include <boost/units/detail/dimension_list.hpp>
 #include <boost/units/detail/sort.hpp>
 
 namespace boost {


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