Boost logo

Boost-Commit :

From: steven_at_[hidden]
Date: 2008-05-15 23:54:33


Author: steven_watanabe
Date: 2008-05-15 23:54:33 EDT (Thu, 15 May 2008)
New Revision: 45416
URL: http://svn.boost.org/trac/boost/changeset/45416

Log:
Removed base_unit and base_dimension inheritance from mpl::long_ to prevent problems with the implicit conversion which MPL so helpfully provides
Added:
   sandbox/units/boost/units/detail/ordinal.hpp (contents, props changed)
Text files modified:
   sandbox/units/boost/units/base_dimension.hpp | 5 +++--
   sandbox/units/boost/units/base_unit.hpp | 5 +++--
   2 files changed, 6 insertions(+), 4 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-15 23:54:33 EDT (Thu, 15 May 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
@@ -16,6 +16,7 @@
 #include <boost/units/static_rational.hpp>
 #include <boost/units/units_fwd.hpp>
 #include <boost/units/detail/dimension_list.hpp>
+#include <boost/units/detail/ordinal.hpp>
 #include <boost/units/detail/prevent_redefinition.hpp>
 
 namespace boost {
@@ -57,7 +58,7 @@
 #endif
>
 class base_dimension :
- public mpl::long_<N>
+ public ordinal<N>
 {
     public:
         /// INTERNAL ONLY

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-15 23:54:33 EDT (Thu, 15 May 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
@@ -17,6 +17,7 @@
 #include <boost/units/units_fwd.hpp>
 #include <boost/units/unit.hpp>
 #include <boost/units/detail/dimension_list.hpp>
+#include <boost/units/detail/ordinal.hpp>
 #include <boost/units/detail/prevent_redefinition.hpp>
 
 namespace boost {
@@ -60,7 +61,7 @@
 #endif
>
 class base_unit :
- public mpl::long_<N>
+ public ordinal<N>
 {
     public:
         /// INTERNAL ONLY

Added: sandbox/units/boost/units/detail/ordinal.hpp
==============================================================================
--- (empty file)
+++ sandbox/units/boost/units/detail/ordinal.hpp 2008-05-15 23:54:33 EDT (Thu, 15 May 2008)
@@ -0,0 +1,49 @@
+// 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)
+
+#ifndef BOOST_UNITS_DETAIL_ORDINAL_HPP_INCLUDED
+#define BOOST_UNITS_DETAIL_ORDINAL_HPP_INCLUDED
+
+#include <boost/mpl/less.hpp>
+#include <boost/mpl/bool.hpp>
+
+namespace boost {
+namespace units {
+
+namespace detail {
+
+struct ordinal_tag {};
+
+}
+
+template<int N>
+struct ordinal {
+ typedef detail::ordinal_tag tag;
+ static const long value = N;
+};
+
+template<int N>
+const long ordinal<N>::value;
+
+}
+
+namespace mpl {
+
+template<>
+struct less_impl<units::detail::ordinal_tag, units::detail::ordinal_tag> {
+ template<class T1, class T2>
+ struct apply : bool_<(T1::value) < (T2::value)> {};
+};
+
+}
+
+}
+
+#endif


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