|
Boost-Commit : |
From: steven_at_[hidden]
Date: 2008-05-14 20:27:40
Author: steven_watanabe
Date: 2008-05-14 20:27:39 EDT (Wed, 14 May 2008)
New Revision: 45377
URL: http://svn.boost.org/trac/boost/changeset/45377
Log:
Removed the last traces of general implicit conversions
Removed:
sandbox/units/boost/units/detail/implicit_conversion.hpp
Text files modified:
sandbox/units/boost/units/unit.hpp | 16 ----------
sandbox/units/libs/units/doc/units.qbk | 18 -----------
sandbox/units/libs/units/example/conversion.cpp | 61 ----------------------------------------
sandbox/units/libs/units/test/fail_implicit_conversion.cpp | 4 --
4 files changed, 0 insertions(+), 99 deletions(-)
Deleted: sandbox/units/boost/units/detail/implicit_conversion.hpp
==============================================================================
--- sandbox/units/boost/units/detail/implicit_conversion.hpp 2008-05-14 20:27:39 EDT (Wed, 14 May 2008)
+++ (empty file)
@@ -1,120 +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_IMPLICIT_CONVERSION_HPP
-#define BOOST_UNITS_IMPLICIT_CONVERSION_HPP
-
-#include <boost/mpl/begin.hpp>
-#include <boost/mpl/size.hpp>
-#include <boost/mpl/next.hpp>
-#include <boost/mpl/deref.hpp>
-#include <boost/mpl/bool.hpp>
-
-#include <boost/units/operators.hpp>
-#include <boost/units/heterogeneous_system.hpp>
-#include <boost/units/reduce_unit.hpp>
-#include <boost/units/units_fwd.hpp>
-
-namespace boost {
-
-namespace units {
-
-namespace detail {
-
-template<int N>
-struct implicit_conversion_impl;
-
-template<class From, class To>
-struct base_unit_is_implicitly_convertible : mpl::false_ {};
-
-template<class From>
-struct base_unit_is_implicitly_convertible<From, BOOST_UNITS_MAKE_HETEROGENEOUS_UNIT(From, typename From::dimension_type)> : mpl::true_ {};
-
-template<bool condition>
-struct implicit_conversion_func;
-
-template<>
-struct implicit_conversion_func<true>
-{
- template<int N, class Begin, class System>
- struct apply
- {
- enum { value = implicit_conversion_impl<N-1>::template apply<typename mpl::next<Begin>::type, System>::value};
- };
-};
-
-template<>
-struct implicit_conversion_func<false>
-{
- template<int N, class Begin, class System>
- struct apply
- {
- enum { value = false };
- };
-};
-
-template<int N>
-struct implicit_conversion_impl
-{
- template<class Begin, class System>
- struct apply
- {
- typedef typename mpl::deref<Begin>::type::tag_type current;
- typedef typename reduce_unit<unit<typename current::dimension_type, System> >::type target_unit;
- enum { value = (implicit_conversion_func<base_unit_is_implicitly_convertible<current, target_unit>::value>::template apply<N, Begin, System>::value) };
- };
-};
-
-template<>
-struct implicit_conversion_impl<0>
-{
- template<class Begin, class System>
- struct apply
- {
- enum { value = true };
- };
-};
-
-template<class From, class To>
-struct unit_is_implicitly_convertible {
- typedef typename reduce_unit<From>::type::system_type::type list;
- typedef mpl::bool_<(implicit_conversion_impl<mpl::size<list>::value>::template apply<typename mpl::begin<list>::type, typename To::system_type>::value)> type;
-};
-
-} // namespace detail
-
-#define BOOST_UNITS_IMPLICIT_CONVERSION(From, To) \
- namespace boost { \
- namespace units { \
- namespace detail { \
- template<> \
- struct base_unit_is_implicitly_convertible<From, To> : mpl::true_ {}; \
- } \
- } \
- }
-
-#define BOOST_UNITS_BASE_IMPLICIT_CONVERSION(From, To) \
- namespace boost { \
- namespace units { \
- namespace detail { \
- template<> \
- struct base_unit_is_implicitly_convertible< \
- From, \
- BOOST_UNITS_MAKE_HETEROGENEOUS_UNIT(To, From::dimension_type) \
- > : mpl::true_ {}; \
- } \
- } \
- }
-
-} // namespace units
-
-} // namespace boost
-
-#endif // BOOST_UNITS_IMPLICIT_CONVERSION_HPP
Modified: sandbox/units/boost/units/unit.hpp
==============================================================================
--- sandbox/units/boost/units/unit.hpp (original)
+++ sandbox/units/boost/units/unit.hpp 2008-05-14 20:27:39 EDT (Wed, 14 May 2008)
@@ -24,7 +24,6 @@
#include <boost/units/is_dimension_list.hpp>
#include <boost/units/reduce_unit.hpp>
#include <boost/units/static_rational.hpp>
-#include <boost/units/detail/implicit_conversion.hpp>
namespace boost {
@@ -82,26 +81,11 @@
> type;
};
-//template<class S1,class S2> struct is_implicitly_convertible;
-
-#ifdef BOOST_UNITS_ENABLE_IMPLICIT_UNIT_CONVERSION
-
-template<class S1, class S2>
-struct is_implicitly_convertible : mpl::true_ {};
-
-#else
-
template<class S1,class S2>
struct is_implicitly_convertible :
boost::is_same<typename reduce_unit<S1>::type, typename reduce_unit<S2>::type>
{ };
-template<class D, class S1, class S2>
-struct is_implicitly_convertible<unit<D, homogeneous_system<S1> >, unit<D, homogeneous_system<S2> > >
- : detail::unit_is_implicitly_convertible<unit<D, homogeneous_system<S1> >, unit<D, homogeneous_system<S2> > >::type {};
-
-#endif
-
/// unit unary plus typeof helper
/// INTERNAL ONLY
template<class Dim,class System>
Modified: sandbox/units/libs/units/doc/units.qbk
==============================================================================
--- sandbox/units/libs/units/doc/units.qbk (original)
+++ sandbox/units/libs/units/doc/units.qbk 2008-05-14 20:27:39 EDT (Wed, 14 May 2008)
@@ -59,7 +59,6 @@
[def __unscale [classref boost::units::unscale unscale]]
[def __BOOST_UNITS_STATIC_CONSTANT [macroref BOOST_UNITS_STATIC_CONSTANT]]
-[def __BOOST_UNITS_ENABLE_IMPLICIT_UNIT_CONVERSIONS [macroref BOOST_UNITS_ENABLE_IMPLICIT_UNIT_CONVERSIONS]]
[def __BOOST_UNITS_DEFINE_CONVERSION_FACTOR [macroref BOOST_UNITS_DEFINE_CONVERSION_FACTOR]]
[def __BOOST_UNITS_DEFINE_CONVERSION_FACTOR_TEMPLATE [macroref BOOST_UNITS_DEFINE_CONVERSION_FACTOR_TEMPLATE]]
@@ -684,23 +683,6 @@
[conversion_output_2]
-While the library default is to enable only those unit conversions for which the conversion of every
-base unit present in a quantity is specifically enabled as implicit, it is possible to
-supersede this behavior and enable all implicit conversions by defining the preprocessor
-constant [___BOOST_UNITS_ENABLE_IMPLICIT_UNIT_CONVERSIONS]. This allows us to do things like the following:
-
-[conversion_snippet_6]
-
-which produces the following output:
-
-[conversion_output_3]
-
-Of course, blindly enabling implicit conversions entails some risk of unnecessary conversions being done
-in the background, with the potential for loss of precision and other related concerns. These issues should
-be seriously considered, and, if possible, implicit conversions limited to cases where it is expressly
-allowed such as in the conversion between two identical units in different unit systems (e.g. seconds in
-SI and CGS systems).
-
[endsect]
[section:UDTExample User Defined Types]
Modified: sandbox/units/libs/units/example/conversion.cpp
==============================================================================
--- sandbox/units/libs/units/example/conversion.cpp (original)
+++ sandbox/units/libs/units/example/conversion.cpp 2008-05-14 20:27:39 EDT (Wed, 14 May 2008)
@@ -42,23 +42,9 @@
velocity (2 cm/s) = 0.02 m s^-1
//]
-//[conversion_output_3
-implicit conversions enabled
-volume (m^3) = 1 m^3
-volume (cm^3) = 1e+06 cm^3
-
-energy (joules) = 1 m^2 kg s^-2
-energy (ergs) = 1e+07 cm^2 g s^-2
-
-velocity (2 m/s) = 2 m s^-1
-velocity (2 cm/s) = 0.02 m s^-1
-//]
-
@endverbatim
**/
-#define BOOST_UNITS_ENABLE_IMPLICIT_UNIT_CONVERSION
-
#include <iostream>
#include <sstream>
#include <algorithm>
@@ -136,40 +122,6 @@
<< "velocity (2 cm/s) = " << v2 << std::endl
<< std::endl;
}
-
- // test implicit unit system conversion
- {
- sstream1 << std::endl
- << "implicit conversions enabled"
- << std::endl;
-
- //[conversion_snippet_6
- quantity<SI::volume> vs(1.0*pow<3>(SI::meter));
- quantity<CGS::volume> vc;
-
- vc = vs;
-
- quantity<SI::energy> es(1.0*SI::joule);
- quantity<CGS::energy> ec;
-
- ec = es;
-
- quantity<SI::velocity> v1 = 2.0*SI::meters/SI::second,
- v2 = 2.0*CGS::centimeters/CGS::second;
- //]
-
- sstream1 << "volume (m^3) = " << vs << std::endl
- << "volume (cm^3) = " << vc << std::endl
- << std::endl;
-
- sstream1 << "energy (joules) = " << es << std::endl
- << "energy (ergs) = " << ec << std::endl
- << std::endl;
-
- sstream1 << "velocity (2 m/s) = " << v1 << std::endl
- << "velocity (2 cm/s) = " << v2 << std::endl
- << std::endl;
- }
sstream2 << "L1 = 2 m" << std::endl;
sstream2 << "L2 = 2 m" << std::endl;
@@ -190,19 +142,6 @@
sstream2 << "velocity (2 m/s) = 2 m s^-1" << std::endl;
sstream2 << "velocity (2 cm/s) = 0.02 m s^-1" << std::endl;
sstream2 << std::endl;
-#ifdef BOOST_UNITS_ENABLE_IMPLICIT_UNIT_CONVERSION
- sstream2 << std::endl;
- sstream2 << "implicit conversions enabled" << std::endl;
- sstream2 << "volume (m^3) = 1 m^3" << std::endl;
- sstream2 << "volume (cm^3) = " << 1e6 << " cm^3" << std::endl;
- sstream2 << std::endl;
- sstream2 << "energy (joules) = 1 m^2 kg s^-2" << std::endl;
- sstream2 << "energy (ergs) = " << 1e7 << " cm^2 g s^-2" << std::endl;
- sstream2 << std::endl;
- sstream2 << "velocity (2 m/s) = 2 m s^-1" << std::endl;
- sstream2 << "velocity (2 cm/s) = 0.02 m s^-1" << std::endl;
- sstream2 << std::endl;
-#endif
std::string str1(sstream1.str());
std::string str2(sstream2.str());
Modified: sandbox/units/libs/units/test/fail_implicit_conversion.cpp
==============================================================================
--- sandbox/units/libs/units/test/fail_implicit_conversion.cpp (original)
+++ sandbox/units/libs/units/test/fail_implicit_conversion.cpp 2008-05-14 20:27:39 EDT (Wed, 14 May 2008)
@@ -24,17 +24,13 @@
#include <boost/units/quantity.hpp>
#include <boost/units/systems/si.hpp>
#include <boost/units/systems/cgs.hpp>
-//#include <boost/units/systems/conversions/convert_si_to_cgs.hpp>
-//#include <boost/units/systems/conversions/convert_cgs_to_si.hpp>
namespace bu = boost::units;
int main(int,char *[])
{
- #ifndef BOOST_UNITS_ENABLE_IMPLICIT_UNIT_CONVERSION
const bu::quantity<bu::SI::length> T1(2.0 * bu::SI::meters);
const bu::quantity<bu::CGS::length> T2 = T1;
- #endif // BOOST_UNITS_ENABLE_IMPLICIT_UNIT_CONVERSION
return 0;
}
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