You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(89) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(208) |
Feb
(76) |
Mar
(55) |
Apr
(74) |
May
(43) |
Jun
(116) |
Jul
(109) |
Aug
(46) |
Sep
(36) |
Oct
(106) |
Nov
(159) |
Dec
(128) |
2007 |
Jan
(54) |
Feb
(225) |
Mar
(200) |
Apr
(229) |
May
(7) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Steven W. <ste...@us...> - 2007-04-15 02:57:05
|
Update of /cvsroot/boost-sandbox/boost-sandbox/boost/units In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv26207/boost-sandbox/boost/units Modified Files: quantity.hpp Log Message: Supress implicit narrowing conversions Index: quantity.hpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/boost/units/quantity.hpp,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- quantity.hpp 13 Apr 2007 04:56:14 -0000 1.22 +++ quantity.hpp 15 Apr 2007 02:57:02 -0000 1.23 @@ -15,8 +15,12 @@ #include <boost/config.hpp> #include <boost/mpl/bool_fwd.hpp> +#include <boost/mpl/and.hpp> +#include <boost/mpl/or.hpp> #include <boost/utility/enable_if.hpp> #include <boost/type_traits/is_convertible.hpp> +#include <boost/type_traits/is_arithmetic.hpp> +#include <boost/type_traits/is_integral.hpp> #include <boost/units/dimensionless_quantity.hpp> #include <boost/units/get_dimension.hpp> @@ -28,6 +32,33 @@ namespace units { +namespace detail { + +template<class Source, class Destination> +struct is_narrowing_conversion_impl : mpl::bool_<(sizeof(Source) > sizeof(Destination))> {}; + +template<class Source, class Destination> +struct is_non_narrowing_conversion : + mpl::and_< + boost::is_convertible<Source, Destination>, + mpl::not_< + mpl::and_< + boost::is_arithmetic<Source>, + boost::is_arithmetic<Destination>, + mpl::or_< + mpl::and_< + is_integral<Destination>, + mpl::not_<is_integral<Source> > + >, + is_narrowing_conversion_impl<Source, Destination> + > + > + > + > +{}; + +} + template<class Q1,class Q2> class conversion_helper; /// class declaration @@ -63,6 +94,28 @@ return *this; } + #ifndef BOOST_NO_SFINAE + + /// implicit conversion between value types is allowed if allowed for value types themselves + template<class YY> + quantity(const quantity<unit<dimension_type,system_type>,YY>& source, + typename boost::enable_if<detail::is_non_narrowing_conversion<YY, Y> >::type* = 0) : + val_(source.value()) + { + BOOST_UNITS_CHECK_LAYOUT_COMPATIBILITY(this_type, Y); + } + + /// implicit conversion between value types is not allowed if not allowed for value types themselves + template<class YY> + explicit quantity(const quantity<unit<dimension_type,system_type>,YY>& source, + typename boost::disable_if<detail::is_non_narrowing_conversion<YY, Y> >::type* = 0) : + val_(static_cast<Y>(source.value())) + { + BOOST_UNITS_CHECK_LAYOUT_COMPATIBILITY(this_type, Y); + } + + #else + /// implicit conversion between value types is allowed if allowed for value types themselves template<class YY> quantity(const quantity<unit<dimension_type,system_type>,YY>& source) : @@ -71,6 +124,8 @@ BOOST_UNITS_CHECK_LAYOUT_COMPATIBILITY(this_type, Y); BOOST_STATIC_ASSERT((boost::is_convertible<YY, Y>::value == true)); } + + #endif /// implicit assignment between value types is allowed if allowed for value types themselves template<class YY> @@ -89,7 +144,12 @@ template<class System2,class Dim2,class YY> explicit quantity(const quantity<unit<Dim2,System2>,YY>& source, - typename boost::disable_if<typename is_implicitly_convertible<unit<Dim2,System2>,unit_type>::type>::type* = 0) + typename boost::disable_if< + mpl::and_< + is_implicitly_convertible<unit<Dim2,System2>,unit_type>, + detail::is_non_narrowing_conversion<YY, Y> + > + >::type* = 0) : val_(conversion_helper<quantity<unit<Dim2,System2>,YY>,this_type>::convert(source).value()) { BOOST_UNITS_CHECK_LAYOUT_COMPATIBILITY(this_type, Y); @@ -99,7 +159,12 @@ /// implicit conversion between different unit systems is allowed if each fundamental dimension is implicitly convertible template<class System2,class Dim2,class YY> quantity(const quantity<unit<Dim2,System2>,YY>& source, - typename boost::enable_if<typename is_implicitly_convertible<unit<Dim2,System2>,unit_type>::type>::type* = 0) + typename boost::enable_if< + mpl::and_< + is_implicitly_convertible<unit<Dim2,System2>,unit_type>, + detail::is_non_narrowing_conversion<YY, Y> + > + >::type* = 0) : val_(conversion_helper<quantity<unit<Dim2,System2>,YY>,this_type>::convert(source).value()) { BOOST_UNITS_CHECK_LAYOUT_COMPATIBILITY(this_type, Y); @@ -199,15 +264,38 @@ return *this; } - + #ifndef BOOST_NO_SFINAE + + /// implicit conversion between value types is allowed if allowed for value types themselves + template<class YY> + quantity(const quantity<unit<dimension_type,system_type>,YY>& source, + typename boost::enable_if<detail::is_non_narrowing_conversion<YY, Y> >::type* = 0) : + val_(source.value()) + { + BOOST_UNITS_CHECK_LAYOUT_COMPATIBILITY(this_type, Y); + } + + /// implicit conversion between value types is not allowed if not allowed for value types themselves + template<class YY> + explicit quantity(const quantity<unit<dimension_type,system_type>,YY>& source, + typename boost::disable_if<detail::is_non_narrowing_conversion<YY, Y> >::type* = 0) : + val_(static_cast<Y>(source.value())) + { + BOOST_UNITS_CHECK_LAYOUT_COMPATIBILITY(this_type, Y); + } + + #else + /// implicit conversion between value types is allowed if allowed for value types themselves template<class YY> quantity(const quantity<unit<dimension_type,system_type>,YY>& source) : val_(source.value()) { BOOST_UNITS_CHECK_LAYOUT_COMPATIBILITY(this_type, Y); - BOOST_STATIC_ASSERT((boost::is_convertible<YY,Y>::value == true)); + BOOST_STATIC_ASSERT((boost::is_convertible<YY, Y>::value == true)); } + + #endif /// implicit assignment between value types is allowed if allowed for value types themselves template<class YY> @@ -220,14 +308,39 @@ return *this; } + #ifndef BOOST_NO_SFINAE + + /// implicit conversion between different unit systems is allowed + template<class System2, class Y2> + quantity(const quantity<unit<dimensionless_type,homogeneous_system<System2> >,Y2>& source, + typename boost::enable_if<detail::is_non_narrowing_conversion<Y2, Y> >::type* = 0) : + val_(source.value()) + { + BOOST_UNITS_CHECK_LAYOUT_COMPATIBILITY(this_type, Y); + } + + /// implicit conversion between different unit systems is allowed + template<class System2, class Y2> + explicit quantity(const quantity<unit<dimensionless_type,homogeneous_system<System2> >,Y2>& source, + typename boost::disable_if<detail::is_non_narrowing_conversion<Y2, Y> >::type* = 0) : + val_(static_cast<Y>(source.value())) + { + BOOST_UNITS_CHECK_LAYOUT_COMPATIBILITY(this_type, Y); + } + + #else + /// implicit conversion between different unit systems is allowed template<class System2, class Y2> quantity(const quantity<unit<dimensionless_type,homogeneous_system<System2> >,Y2>& source) : val_(source.value()) { BOOST_UNITS_CHECK_LAYOUT_COMPATIBILITY(this_type, Y); + BOOST_STATIC_ASSERT((boost::is_convertible<Y2, Y>::value == true)); } + #endif + /// conversion between different unit systems is explicit when /// the units are not equivalent. template<class System2, class Y2> |
From: Steven W. <ste...@us...> - 2007-04-15 02:57:05
|
Update of /cvsroot/boost-sandbox/boost-sandbox/libs/units/test In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv26207/boost-sandbox/libs/units/test Modified Files: test_quantity.cpp Log Message: Supress implicit narrowing conversions Index: test_quantity.cpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/libs/units/test/test_quantity.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- test_quantity.cpp 29 Mar 2007 20:03:27 -0000 1.2 +++ test_quantity.cpp 15 Apr 2007 02:57:02 -0000 1.3 @@ -50,11 +50,11 @@ BOOST_UNITS_CHECK_CLOSE(E5.value(),float(E_)); // implicit operator= value_type conversion - const bu::quantity<bu::energy,float> E7 = E2; - BOOST_UNITS_CHECK_CLOSE(E7.value(),float(E_)); + //const bu::quantity<bu::energy,float> E7 = E2; + //BOOST_UNITS_CHECK_CLOSE(E7.value(),float(E_)); - const bu::quantity<bu::energy,long> E8 = E2; - BOOST_CHECK(E8.value() == long(E_)); + //const bu::quantity<bu::energy,long> E8 = E2; + //BOOST_CHECK(E8.value() == long(E_)); // const construction bu::quantity<bu::energy> E9(E2); |
From: Steven W. <ste...@us...> - 2007-04-15 02:09:25
|
Update of /cvsroot/boost-sandbox/boost-sandbox/boost/units In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv8273/boost-sandbox/boost/units Modified Files: base_dimension.hpp Log Message: More comments + INTERNAL ONLY Index: base_dimension.hpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/boost/units/base_dimension.hpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- base_dimension.hpp 15 Apr 2007 01:47:05 -0000 1.5 +++ base_dimension.hpp 15 Apr 2007 02:09:19 -0000 1.6 @@ -39,12 +39,14 @@ } -/// this must be in namespace boost::units so that ADL +/// This must be in namespace boost::units so that ADL /// will work with friend functions defined inline. /// INTERNAL ONLY template<long N> struct long_ {}; +/// Ditto. +/// INTERNAL ONLY template<class T, long N> struct base_dimension_pair {}; @@ -54,8 +56,8 @@ template<class T> detail::no boost_units_prevent_double_definition(const T&) { return(detail::no()); } -/// Defines a base dimensions. To define a dimension you need to provide -/// the derived class and a unique integer. +/// Defines a base dimension. To define a dimension you need to provide +/// the derived class (CRTP) and a unique integer. /// struct my_dimension : boost::units::base_dimension<my_dimension, 1> {}; /// It is designed so that you will get an error message if you try /// to use the same value in multiple definitions. @@ -66,7 +68,11 @@ sizeof(boost_units_prevent_double_definition(units::base_dimension_pair<Derived, N>())) != sizeof(detail::yes) >::type> struct base_dimension : mpl::long_<N> { + /// Register this ordinal + /// INTERNAL ONLY friend detail::yes boost_units_prevent_double_definition(const units::long_<N>&) { return(detail::yes()); } + /// But make sure we can identify the current instantiation! + /// INTERNAL ONLY friend detail::yes boost_units_prevent_double_definition(const units::base_dimension_pair<Derived, N>&) { return(detail::yes()); } typedef base_dimension this_type; typedef mpl::long_<N> value; |
From: Steven W. <ste...@us...> - 2007-04-15 01:53:58
|
Update of /cvsroot/boost-sandbox/boost-sandbox/libs/units/test In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv2065/boost-sandbox/libs/units/test Modified Files: Jamfile.v2 Added Files: fail_base_dimension.cpp Log Message: make sure that using an ordinal twice fails Index: Jamfile.v2 =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/libs/units/test/Jamfile.v2,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Jamfile.v2 15 Apr 2007 01:40:40 -0000 1.2 +++ Jamfile.v2 15 Apr 2007 01:53:58 -0000 1.3 @@ -38,6 +38,7 @@ [ compile-fail fail_unit_quantity_subtract.cpp : $(UNIT_REQUIREMENTS) : ] [ compile-fail fail_adl_detail.cpp : $(UNIT_REQUIREMENTS) : ] [ compile-fail fail_heterogeneous_unit.cpp : $(UNIT_REQUIREMENTS) : ] + [ compile-fail fail_base_dimension.cpp : $(UNIT_REQUIREMENTS) : ] ; } --- NEW FILE: fail_base_dimension.cpp --- // 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) /** \file \brief fail_base_dimension.cpp \detailed make sure that trying to use the same ordinal for multiple base dimensions fails. Output: @verbatim @endverbatim **/ #include <boost/units/base_dimension.hpp> struct dim1 : boost::units::base_dimension<dim1, 1> {}; struct dim2 : boost::units::base_dimension<dim2, 1> {}; int main() { } |
From: Steven W. <ste...@us...> - 2007-04-15 01:47:06
|
Update of /cvsroot/boost-sandbox/boost-sandbox/boost/units In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv32068/boost-sandbox/boost/units Modified Files: base_dimension.hpp Log Message: Put the helper structs in namespace detail Index: base_dimension.hpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/boost/units/base_dimension.hpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- base_dimension.hpp 15 Apr 2007 01:41:48 -0000 1.4 +++ base_dimension.hpp 15 Apr 2007 01:47:05 -0000 1.5 @@ -23,6 +23,8 @@ namespace units { +namespace detail { + typedef char no; struct yes { no dummy[2]; }; @@ -35,6 +37,8 @@ template<> struct ordinal_has_already_been_defined<false> { typedef void type; }; +} + /// this must be in namespace boost::units so that ADL /// will work with friend functions defined inline. /// INTERNAL ONLY @@ -48,7 +52,7 @@ /// we need a mangled name because it must be found by ADL /// INTERNAL ONLY template<class T> -no boost_units_prevent_double_definition(const T&) { return(no()); } +detail::no boost_units_prevent_double_definition(const T&) { return(detail::no()); } /// Defines a base dimensions. To define a dimension you need to provide /// the derived class and a unique integer. @@ -57,13 +61,13 @@ /// to use the same value in multiple definitions. template<class Derived, long N, - class = typename ordinal_has_already_been_defined< - sizeof(boost_units_prevent_double_definition(units::long_<N>())) == sizeof(yes) && - sizeof(boost_units_prevent_double_definition(units::base_dimension_pair<Derived, N>())) != sizeof(yes) + class = typename detail::ordinal_has_already_been_defined< + sizeof(boost_units_prevent_double_definition(units::long_<N>())) == sizeof(detail::yes) && + sizeof(boost_units_prevent_double_definition(units::base_dimension_pair<Derived, N>())) != sizeof(detail::yes) >::type> struct base_dimension : mpl::long_<N> { - friend yes boost_units_prevent_double_definition(const units::long_<N>&) { return(yes()); } - friend yes boost_units_prevent_double_definition(const units::base_dimension_pair<Derived, N>&) { return(yes()); } + friend detail::yes boost_units_prevent_double_definition(const units::long_<N>&) { return(detail::yes()); } + friend detail::yes boost_units_prevent_double_definition(const units::base_dimension_pair<Derived, N>&) { return(detail::yes()); } typedef base_dimension this_type; typedef mpl::long_<N> value; typedef dimension_list<dim<Derived,static_rational<1> >, dimensionless_type> type; |
From: Steven W. <ste...@us...> - 2007-04-15 01:41:48
|
Update of /cvsroot/boost-sandbox/boost-sandbox/boost/units In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv29959/boost-sandbox/boost/units Modified Files: base_dimension.hpp Log Message: make sure that we can refer to base_dimension without causing erros Index: base_dimension.hpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/boost/units/base_dimension.hpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- base_dimension.hpp 14 Apr 2007 21:52:00 -0000 1.3 +++ base_dimension.hpp 15 Apr 2007 01:41:48 -0000 1.4 @@ -41,10 +41,14 @@ template<long N> struct long_ {}; +template<class T, long N> +struct base_dimension_pair {}; + /// Again this needs to be in the same namespace as long_ +/// we need a mangled name because it must be found by ADL /// INTERNAL ONLY -template<long N> -no boost_units_prevent_double_definition(units::long_<N>) { return(no()); } +template<class T> +no boost_units_prevent_double_definition(const T&) { return(no()); } /// Defines a base dimensions. To define a dimension you need to provide /// the derived class and a unique integer. @@ -54,11 +58,13 @@ template<class Derived, long N, class = typename ordinal_has_already_been_defined< - sizeof(boost_units_prevent_double_definition(units::long_<N>())) == sizeof(yes) + sizeof(boost_units_prevent_double_definition(units::long_<N>())) == sizeof(yes) && + sizeof(boost_units_prevent_double_definition(units::base_dimension_pair<Derived, N>())) != sizeof(yes) >::type> struct base_dimension : mpl::long_<N> { - friend yes boost_units_prevent_double_definition(units::long_<N>) { return(yes()); } - typedef Derived this_type; + friend yes boost_units_prevent_double_definition(const units::long_<N>&) { return(yes()); } + friend yes boost_units_prevent_double_definition(const units::base_dimension_pair<Derived, N>&) { return(yes()); } + typedef base_dimension this_type; typedef mpl::long_<N> value; typedef dimension_list<dim<Derived,static_rational<1> >, dimensionless_type> type; }; |
From: Steven W. <ste...@us...> - 2007-04-15 01:40:40
|
Update of /cvsroot/boost-sandbox/boost-sandbox/libs/units/test In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv29538/boost-sandbox/libs/units/test Modified Files: Jamfile.v2 Log Message: make sure that we can use base_dimension reliably Index: Jamfile.v2 =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/libs/units/test/Jamfile.v2,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- Jamfile.v2 16 Mar 2007 18:29:54 -0000 1.1.1.1 +++ Jamfile.v2 15 Apr 2007 01:40:40 -0000 1.2 @@ -7,7 +7,7 @@ # accomanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt -UNIT_REQUIREMENTS = <include>$(BOOST_ROOT) <include>../../.. ; +UNIT_REQUIREMENTS = <include>$(BOOST_ROOT) <include>../../.. <warnings>all ; import testing ; @@ -20,6 +20,7 @@ [ run test_quantity.cpp : : : $(UNIT_REQUIREMENTS) : ] [ run test_unit.cpp : : : $(UNIT_REQUIREMENTS) : ] [ run test_conversion.cpp : : : $(UNIT_REQUIREMENTS) : ] + [ run test_base_dimension.cpp : : : $(UNIT_REQUIREMENTS) : ] [ compile-fail fail_implicit_conversion.cpp : $(UNIT_REQUIREMENTS) : ] [ compile-fail fail_quantity_construct.cpp : $(UNIT_REQUIREMENTS) : ] [ compile-fail fail_quantity_assign.cpp : $(UNIT_REQUIREMENTS) : ] |
From: Steven W. <ste...@us...> - 2007-04-15 01:40:19
|
Update of /cvsroot/boost-sandbox/boost-sandbox/libs/units/test In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv29492/boost-sandbox/libs/units/test Added Files: test_base_dimension.cpp Log Message: make sure that we can use base_dimension reliably --- NEW FILE: test_base_dimension.cpp --- // 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) /** \file \brief test_base_dimension.cpp \detailed Test base_dimension class. Output: @verbatim @endverbatim **/ #include <boost/units/base_dimension.hpp> struct dimension : boost::units::base_dimension<dimension, 1> { typedef boost::units::base_dimension<dimension, 1> base; }; int main() { } |
From: Steven W. <ste...@us...> - 2007-04-14 21:55:55
|
Update of /cvsroot/boost-sandbox/boost-sandbox/boost/units In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv6416/boost-sandbox/boost/units Modified Files: is_dimensionless_quantity.hpp is_dimensionless_unit.hpp Log Message: new base_dimension and made all tests and examples pass Index: is_dimensionless_quantity.hpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/boost/units/is_dimensionless_quantity.hpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- is_dimensionless_quantity.hpp 13 Apr 2007 04:53:44 -0000 1.1 +++ is_dimensionless_quantity.hpp 14 Apr 2007 21:55:54 -0000 1.2 @@ -28,4 +28,4 @@ } // namespace boost -#endif // BOOST_UNITS_IS_DIMENSIONLESS_QUANTITY_HPP \ No newline at end of file +#endif // BOOST_UNITS_IS_DIMENSIONLESS_QUANTITY_HPP Index: is_dimensionless_unit.hpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/boost/units/is_dimensionless_unit.hpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- is_dimensionless_unit.hpp 13 Apr 2007 04:53:44 -0000 1.1 +++ is_dimensionless_unit.hpp 14 Apr 2007 21:55:54 -0000 1.2 @@ -28,4 +28,4 @@ } // namespace boost -#endif // BOOST_UNITS_IS_DIMENSIONLESS_UNIT_HPP \ No newline at end of file +#endif // BOOST_UNITS_IS_DIMENSIONLESS_UNIT_HPP |
From: Steven W. <ste...@us...> - 2007-04-14 21:53:23
|
Update of /cvsroot/boost-sandbox/boost-sandbox/boost/units/systems In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv5562/boost-sandbox/boost/units/systems Modified Files: physical_units.hpp Log Message: new base_dimension and made all tests and examples pass Index: physical_units.hpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/boost/units/systems/physical_units.hpp,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- physical_units.hpp 13 Apr 2007 06:08:52 -0000 1.17 +++ physical_units.hpp 14 Apr 2007 21:53:22 -0000 1.18 @@ -30,15 +30,15 @@ namespace units { -BOOST_UNITS_REGISTER_BASE_DIMENSION(length_dim,-9); ///> base dimension of length -BOOST_UNITS_REGISTER_BASE_DIMENSION(mass_dim,-8); ///> base dimension of mass -BOOST_UNITS_REGISTER_BASE_DIMENSION(time_dim,-7); ///> base dimension of time -BOOST_UNITS_REGISTER_BASE_DIMENSION(current_dim,-6); ///> base dimension of current -BOOST_UNITS_REGISTER_BASE_DIMENSION(temperature_dim,-5); ///> base dimension of temperature -BOOST_UNITS_REGISTER_BASE_DIMENSION(amount_dim,-4); ///> base dimension of amount -BOOST_UNITS_REGISTER_BASE_DIMENSION(luminous_intensity_dim,-3); ///> base dimension of luminous intensity -BOOST_UNITS_REGISTER_BASE_DIMENSION(plane_angle_dim,-2); ///> base dimension of plane angle -BOOST_UNITS_REGISTER_BASE_DIMENSION(solid_angle_dim,-1); ///> base dimension of solid angle +struct length_dim : boost::units::base_dimension<length_dim, -9> {}; ///> base dimension of length +struct mass_dim : boost::units::base_dimension<mass_dim,-8> {}; ///> base dimension of mass +struct time_dim : boost::units::base_dimension<time_dim,-7> {}; ///> base dimension of time +struct current_dim : boost::units::base_dimension<current_dim,-6> {}; ///> base dimension of current +struct temperature_dim : boost::units::base_dimension<temperature_dim,-5> {}; ///> base dimension of temperature +struct amount_dim : boost::units::base_dimension<amount_dim,-4> {}; ///> base dimension of amount +struct luminous_intensity_dim : boost::units::base_dimension<luminous_intensity_dim,-3> {}; ///> base dimension of luminous intensity +struct plane_angle_dim : boost::units::base_dimension<plane_angle_dim,-2> {}; ///> base dimension of plane angle +struct solid_angle_dim : boost::units::base_dimension<solid_angle_dim,-1> {}; ///> base dimension of solid angle } // namespace units |
Update of /cvsroot/boost-sandbox/boost-sandbox/boost/units In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv4785/boost-sandbox/boost/units Modified Files: base_dimension.hpp dimensionless_quantity.hpp dimensionless_type.hpp dimensionless_unit.hpp dimension_list.hpp get_dimension.hpp get_system.hpp is_dim.hpp is_dimensionless.hpp is_dimension_list.hpp is_quantity.hpp is_quantity_of_dimension.hpp is_quantity_of_system.hpp is_unit.hpp is_unit_of_dimension.hpp is_unit_of_system.hpp ordinal.hpp units_fwd.hpp Log Message: new base_dimension and made all tests and examples pass Index: get_dimension.hpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/boost/units/get_dimension.hpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- get_dimension.hpp 13 Apr 2007 04:54:29 -0000 1.1 +++ get_dimension.hpp 14 Apr 2007 21:52:00 -0000 1.2 @@ -35,4 +35,4 @@ } // namespace boost -#endif // BOOST_UNITS_GET_DIMENSION_HPP \ No newline at end of file +#endif // BOOST_UNITS_GET_DIMENSION_HPP Index: dimension_list.hpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/boost/units/dimension_list.hpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- dimension_list.hpp 13 Apr 2007 05:45:51 -0000 1.1 +++ dimension_list.hpp 14 Apr 2007 21:52:00 -0000 1.2 @@ -47,4 +47,4 @@ #endif -#endif // BOOST_UNITS_DIMENSION_LIST_HPP \ No newline at end of file +#endif // BOOST_UNITS_DIMENSION_LIST_HPP Index: is_quantity_of_system.hpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/boost/units/is_quantity_of_system.hpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- is_quantity_of_system.hpp 13 Apr 2007 04:53:44 -0000 1.1 +++ is_quantity_of_system.hpp 14 Apr 2007 21:52:00 -0000 1.2 @@ -11,7 +11,7 @@ #ifndef BOOST_UNITS_IS_QUANTITY_OF_SYSTEM_HPP #define BOOST_UNITS_IS_QUANTITY_OF_SYSTEM_HPP -#include <boost/units/mpl/bool.hpp> +#include <boost/mpl/bool.hpp> #include <boost/units/units_fwd.hpp> namespace boost { @@ -35,4 +35,4 @@ } // namespace boost -#endif // BOOST_UNITS_IS_QUANTITY_OF_SYSTEM_HPP \ No newline at end of file +#endif // BOOST_UNITS_IS_QUANTITY_OF_SYSTEM_HPP Index: units_fwd.hpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/boost/units/units_fwd.hpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- units_fwd.hpp 13 Apr 2007 06:08:52 -0000 1.3 +++ units_fwd.hpp 14 Apr 2007 21:52:00 -0000 1.4 @@ -48,4 +48,4 @@ } // namespace boost -#endif // BOOST_UNITS_UNITSFWD_HPP \ No newline at end of file +#endif // BOOST_UNITS_UNITSFWD_HPP Index: ordinal.hpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/boost/units/ordinal.hpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- ordinal.hpp 13 Apr 2007 06:08:08 -0000 1.1 +++ ordinal.hpp 14 Apr 2007 21:52:00 -0000 1.2 @@ -34,4 +34,4 @@ #endif -#endif // BOOST_UNITS_ORDINAL_HPP \ No newline at end of file +#endif // BOOST_UNITS_ORDINAL_HPP Index: is_dimension_list.hpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/boost/units/is_dimension_list.hpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- is_dimension_list.hpp 13 Apr 2007 06:06:44 -0000 1.1 +++ is_dimension_list.hpp 14 Apr 2007 21:52:00 -0000 1.2 @@ -39,4 +39,4 @@ } // namespace boost -#endif // BOOST_UNITS_IS_DIMENSION_LIST_HPP \ No newline at end of file +#endif // BOOST_UNITS_IS_DIMENSION_LIST_HPP Index: dimensionless_unit.hpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/boost/units/dimensionless_unit.hpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- dimensionless_unit.hpp 13 Apr 2007 05:05:28 -0000 1.1 +++ dimensionless_unit.hpp 14 Apr 2007 21:52:00 -0000 1.2 @@ -30,4 +30,4 @@ } // namespace boost -#endif // BOOST_UNITS_DIMENSIONLESS_UNIT_HPP \ No newline at end of file +#endif // BOOST_UNITS_DIMENSIONLESS_UNIT_HPP Index: base_dimension.hpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/boost/units/base_dimension.hpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- base_dimension.hpp 13 Apr 2007 06:08:52 -0000 1.2 +++ base_dimension.hpp 14 Apr 2007 21:52:00 -0000 1.3 @@ -11,70 +11,60 @@ #ifndef BOOST_UNITS_BASE_DIMENSION_HPP #define BOOST_UNITS_BASE_DIMENSION_HPP -#include <boost/mpl/int.hpp> -#include <boost/mpl/list.hpp> +#include <boost/mpl/long.hpp> #include <boost/units/config.hpp> #include <boost/units/static_rational.hpp> +#include <boost/units/dim.hpp> +#include <boost/units/dimension_list.hpp> #include <boost/units/units_fwd.hpp> namespace boost { namespace units { -/// A utility class for defining base dimensions. -template<long N> struct base_dimension; +typedef char no; +struct yes { no dummy[2]; }; -/// each specialization must be separately instantiated in boost::units namespace to prevent duplication of tag values -#define BOOST_UNITS_REGISTER_BASE_DIMENSION(name, N) \ -template<> \ -struct base_dimension<N> : \ - public mpl::int_<N> \ -{ \ - typedef base_dimension<N> this_type; \ - typedef mpl::int_<N> value; \ - \ - typedef make_dimension_list< mpl::list< dim< this_type,static_rational<1> > > >::type type; \ -}; \ - \ -typedef base_dimension<N> name \ +template<bool> +struct ordinal_has_already_been_defined; -} // namespace units +template<> +struct ordinal_has_already_been_defined<true> {}; -} // namespace boost +template<> +struct ordinal_has_already_been_defined<false> { typedef void type; }; -#if BOOST_UNITS_HAS_BOOST_TYPEOF +/// this must be in namespace boost::units so that ADL +/// will work with friend functions defined inline. +/// INTERNAL ONLY +template<long N> +struct long_ {}; -#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP() +/// Again this needs to be in the same namespace as long_ +/// INTERNAL ONLY +template<long N> +no boost_units_prevent_double_definition(units::long_<N>) { return(no()); } -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::units::base_dimension, 1) +/// Defines a base dimensions. To define a dimension you need to provide +/// the derived class and a unique integer. +/// struct my_dimension : boost::units::base_dimension<my_dimension, 1> {}; +/// It is designed so that you will get an error message if you try +/// to use the same value in multiple definitions. +template<class Derived, + long N, + class = typename ordinal_has_already_been_defined< + sizeof(boost_units_prevent_double_definition(units::long_<N>())) == sizeof(yes) + >::type> +struct base_dimension : mpl::long_<N> { + friend yes boost_units_prevent_double_definition(units::long_<N>) { return(yes()); } + typedef Derived this_type; + typedef mpl::long_<N> value; + typedef dimension_list<dim<Derived,static_rational<1> >, dimensionless_type> type; +}; -#endif +} // namespace units -// doesn't work with g++ for some reason -//namespace boost { -// -//namespace units { -// -///// A utility class for defining base dimensions. -//template<long N> struct base_dimension; -// -//} // namespace units -// -//} // namespace boost -// -///// each specialization must be separately instantiated in boost::units namespace to prevent duplication of tag values -//#define BOOST_UNITS_REGISTER_BASE_DIMENSION(name, N) \ -//template<> \ -//struct boost::units::base_dimension<N> : \ -// public boost::mpl::int_<N> \ -//{ \ -// typedef boost::units::base_dimension<N> this_type; \ -// typedef boost::mpl::int_<N> value; \ -// \ -// typedef boost::units::make_dimension_list< boost::mpl::list< boost::units::dim< this_type,boost::units::static_rational<1> > > >::type type; \ -//}; \ -// \ -//typedef boost::units::base_dimension<N> name \ +} // namespace boost #endif // BOOST_UNITS_BASE_DIMENSION_HPP Index: is_dim.hpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/boost/units/is_dim.hpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- is_dim.hpp 13 Apr 2007 06:05:58 -0000 1.1 +++ is_dim.hpp 14 Apr 2007 21:52:00 -0000 1.2 @@ -34,4 +34,4 @@ } // namespace boost -#endif // BOOST_UNITS_IS_DIM_HPP \ No newline at end of file +#endif // BOOST_UNITS_IS_DIM_HPP Index: is_unit.hpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/boost/units/is_unit.hpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- is_unit.hpp 13 Apr 2007 04:53:44 -0000 1.1 +++ is_unit.hpp 14 Apr 2007 21:52:00 -0000 1.2 @@ -32,4 +32,4 @@ } // namespace boost -#endif // BOOST_UNITS_IS_UNIT_HPP \ No newline at end of file +#endif // BOOST_UNITS_IS_UNIT_HPP Index: dimensionless_quantity.hpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/boost/units/dimensionless_quantity.hpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- dimensionless_quantity.hpp 13 Apr 2007 05:05:27 -0000 1.1 +++ dimensionless_quantity.hpp 14 Apr 2007 21:52:00 -0000 1.2 @@ -29,4 +29,4 @@ } // namespace boost -#endif // BOOST_UNITS_DIMENSIONLESS_QUANTITY_HPP \ No newline at end of file +#endif // BOOST_UNITS_DIMENSIONLESS_QUANTITY_HPP Index: is_dimensionless.hpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/boost/units/is_dimensionless.hpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- is_dimensionless.hpp 13 Apr 2007 04:53:44 -0000 1.1 +++ is_dimensionless.hpp 14 Apr 2007 21:52:00 -0000 1.2 @@ -38,4 +38,4 @@ } // namespace boost -#endif // BOOST_UNITS_IS_DIMENSIONLESS_HPP \ No newline at end of file +#endif // BOOST_UNITS_IS_DIMENSIONLESS_HPP Index: is_quantity.hpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/boost/units/is_quantity.hpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- is_quantity.hpp 13 Apr 2007 04:53:44 -0000 1.1 +++ is_quantity.hpp 14 Apr 2007 21:52:00 -0000 1.2 @@ -33,4 +33,4 @@ } // namespace boost -#endif // BOOST_UNITS_IS_QUANTITY_HPP \ No newline at end of file +#endif // BOOST_UNITS_IS_QUANTITY_HPP Index: get_system.hpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/boost/units/get_system.hpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- get_system.hpp 13 Apr 2007 04:54:30 -0000 1.1 +++ get_system.hpp 14 Apr 2007 21:52:00 -0000 1.2 @@ -35,4 +35,4 @@ } // namespace boost -#endif // BOOST_UNITS_GET_SYSTEM_HPP \ No newline at end of file +#endif // BOOST_UNITS_GET_SYSTEM_HPP Index: is_quantity_of_dimension.hpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/boost/units/is_quantity_of_dimension.hpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- is_quantity_of_dimension.hpp 13 Apr 2007 04:53:44 -0000 1.1 +++ is_quantity_of_dimension.hpp 14 Apr 2007 21:52:00 -0000 1.2 @@ -11,7 +11,7 @@ #ifndef BOOST_UNITS_IS_QUANTITY_OF_DIMENSION_HPP #define BOOST_UNITS_IS_QUANTITY_OF_DIMENSION_HPP -#include <boost/units/mpl/bool.hpp> +#include <boost/mpl/bool.hpp> #include <boost/units/units_fwd.hpp> namespace boost { @@ -33,4 +33,4 @@ } // namespace boost -#endif // BOOST_UNITS_IS_QUANTITY_OF_DIMENSION_HPP \ No newline at end of file +#endif // BOOST_UNITS_IS_QUANTITY_OF_DIMENSION_HPP Index: is_unit_of_dimension.hpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/boost/units/is_unit_of_dimension.hpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- is_unit_of_dimension.hpp 13 Apr 2007 04:53:44 -0000 1.1 +++ is_unit_of_dimension.hpp 14 Apr 2007 21:52:00 -0000 1.2 @@ -11,7 +11,7 @@ #ifndef BOOST_UNITS_IS_UNIT_OF_DIMENSION_HPP #define BOOST_UNITS_IS_UNIT_OF_DIMENSION_HPP -#include <boost/units/mpl/bool.hpp> +#include <boost/mpl/bool.hpp> #include <boost/units/units_fwd.hpp> namespace boost { @@ -33,4 +33,4 @@ } // namespace boost -#endif // BOOST_UNITS_IS_UNIT_OF_DIMENSION_HPP \ No newline at end of file +#endif // BOOST_UNITS_IS_UNIT_OF_DIMENSION_HPP Index: is_unit_of_system.hpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/boost/units/is_unit_of_system.hpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- is_unit_of_system.hpp 13 Apr 2007 04:53:44 -0000 1.1 +++ is_unit_of_system.hpp 14 Apr 2007 21:52:00 -0000 1.2 @@ -11,7 +11,7 @@ #ifndef BOOST_UNITS_IS_UNIT_OF_SYSTEM_HPP #define BOOST_UNITS_IS_UNIT_OF_SYSTEM_HPP -#include <boost/units/mpl/bool.hpp> +#include <boost/mpl/bool.hpp> #include <boost/units/units_fwd.hpp> namespace boost { @@ -33,4 +33,4 @@ } // namespace boost -#endif // BOOST_UNITS_IS_UNIT_OF_SYSTEM_HPP \ No newline at end of file +#endif // BOOST_UNITS_IS_UNIT_OF_SYSTEM_HPP Index: dimensionless_type.hpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/boost/units/dimensionless_type.hpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- dimensionless_type.hpp 13 Apr 2007 06:08:52 -0000 1.2 +++ dimensionless_type.hpp 14 Apr 2007 21:52:00 -0000 1.3 @@ -40,4 +40,4 @@ #endif -#endif // BOOST_UNITS_DIMENSIONLESS_TYPE_HPP \ No newline at end of file +#endif // BOOST_UNITS_DIMENSIONLESS_TYPE_HPP |
From: Steven W. <ste...@us...> - 2007-04-14 21:52:13
|
Update of /cvsroot/boost-sandbox/boost-sandbox/libs/units/example In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv4785/boost-sandbox/libs/units/example Modified Files: test_system.hpp Log Message: new base_dimension and made all tests and examples pass Index: test_system.hpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/libs/units/example/test_system.hpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- test_system.hpp 13 Apr 2007 06:09:44 -0000 1.6 +++ test_system.hpp 14 Apr 2007 21:52:00 -0000 1.7 @@ -26,9 +26,9 @@ namespace units { //[test_system_snippet_1 -BOOST_UNITS_REGISTER_BASE_DIMENSION(length_dim,1); ///> base dimension of length -BOOST_UNITS_REGISTER_BASE_DIMENSION(mass_dim,2); ///> base dimension of mass -BOOST_UNITS_REGISTER_BASE_DIMENSION(time_dim,3); ///> base dimension of time +struct length_dim : boost::units::base_dimension<length_dim, 1> {}; ///> base dimension of length +struct mass_dim : boost::units::base_dimension<mass_dim,2> {}; ///> base dimension of mass +struct time_dim : boost::units::base_dimension<time_dim,3> {}; ///> base dimension of time //typedef base_dimension<1> length_dim; //typedef base_dimension<2> mass_dim; //typedef base_dimension<3> time_dim; |
From: Steven W. <ste...@us...> - 2007-04-14 21:52:13
|
Update of /cvsroot/boost-sandbox/boost-sandbox/libs/units/test In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv4785/boost-sandbox/libs/units/test Modified Files: test_header.hpp Log Message: new base_dimension and made all tests and examples pass Index: test_header.hpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/libs/units/test/test_header.hpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- test_header.hpp 12 Apr 2007 20:41:49 -0000 1.6 +++ test_header.hpp 14 Apr 2007 21:52:00 -0000 1.7 @@ -26,6 +26,9 @@ #include <boost/test/minimal.hpp> +#include <boost/units/ordinal.hpp> +#include <boost/units/base_dimension.hpp> +#include <boost/units/derived_dimension.hpp> #include <boost/units/static_constant.hpp> #include <boost/units/quantity.hpp> #include <boost/units/io.hpp> @@ -36,9 +39,9 @@ namespace units { -BOOST_UNITS_REGISTER_BASE_DIMENSION(length_dim, 1); -BOOST_UNITS_REGISTER_BASE_DIMENSION(mass_dim, 2); -BOOST_UNITS_REGISTER_BASE_DIMENSION(time_dim, 3); +struct length_dim : boost::units::base_dimension<length_dim, 1> {}; ///> base dimension of length +struct mass_dim : boost::units::base_dimension<mass_dim,2> {}; ///> base dimension of mass +struct time_dim : boost::units::base_dimension<time_dim,3> {}; ///> base dimension of time typedef length_dim::type length_type; typedef mass_dim::type mass_type; |
From: Matthias S. <mat...@us...> - 2007-04-13 19:44:06
|
Update of /cvsroot/boost-sandbox/boost-sandbox/libs/units/example In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv6008/libs/units/example Modified Files: unit_example_22.cpp Log Message: minor changes Index: unit_example_22.cpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/libs/units/example/unit_example_22.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- unit_example_22.cpp 11 Apr 2007 21:24:04 -0000 1.15 +++ unit_example_22.cpp 13 Apr 2007 19:44:04 -0000 1.16 @@ -433,6 +433,10 @@ blahblah operator+(const blah&) { return blahblah(); } +template<typename I,I N,I D> +class static_rational +{ }; + int main() { using namespace boost; |
From: Matthias S. <mat...@us...> - 2007-04-13 19:42:27
|
Update of /cvsroot/boost-sandbox/boost-sandbox/boost/units In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv5055/boost/units Added Files: new_static_rational.hpp Log Message: non-functional static_rational for separate consideration for Boost --- NEW FILE: new_static_rational.hpp --- // 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_STATIC_RATIONAL_HPP #define BOOST_STATIC_RATIONAL_HPP #include <cmath> #include <complex> #include <boost/math/common_factor_ct.hpp> #include <boost/mpl/arithmetic.hpp> #include <boost/type_traits/is_same.hpp> /// \file /// \brief Compile-time rational numbers and operators. namespace boost { namespace detail { struct static_rational_tag {}; } // namespace detail /// Compile time rational number. /** This is an implementation of a compile time rational number, where @c static_rational<N,D> represents a rational number with numerator @c N and denominator @c D. Because of the potential for ambiguity arising from multiple equivalent values of @c static_rational (e.g. @c static_rational<6,2>==static_rational<3>), static rationals should always be accessed through @c static_rational<N,D>::type. Template specialization prevents instantiation of zero denominators (i.e. @c static_rational<N,0>). The following compile-time arithmetic operators are provided for static_rational variables only (no operators are defined between long and static_rational): - @c static_negate - @c static_add - @c static_subtract - @c static_multiply - @c static_divide Neither @c static_power nor @c static_root are defined for @c static_rational. This is because template types may not be floating point values, while powers and roots of rational numbers can produce floating point values. */ template<I N,I D = 1,typename I = long> class static_rational { private: template<int_type Value> struct static_abs { BOOST_STATIC_CONSTANT(int_type,value) = Value < 0 ? -Value : Value; }; /// greatest common divisor of N and D // need cast to signed because static_gcd returns unsigned long static const int_type nabs = static_abs<N>::value, dabs = static_abs<D>::value, den = static_cast<int_type>(boost::math::static_gcd<nabs,dabs>::value), Numerator = N/den, Denominator = D/den; public: // for mpl arithmetic support typedef detail::static_rational_tag tag; typedef static_rational<N,D,I> this_type; typedef I int_type; typedef static_rational<Numerator,Denominator,I> type; static int_type numerator() { return Numerator; } static int_type denominator() { return Denominator; } static_rational() { } //~static_rational() { } // // static rationals are implicitly convertible if reduced types are the same // template<integer_type NN,integer_type DD> // operator static_rational<NN,DD>() // { // BOOST_STATIC_ASSERT((boost::is_same<type,typename static_rational<NN,DD>::type>::value == true)); // // return static_rational<NN,DD>(); // } }; // prohibit zero denominator template<integer_type N,typename I> class static_rational<N,0,I>; /// get decimal value of @c static_rational template<class T,integer_type N,integer_type D> typename divide_typeof_helper<T,T>::type value(const static_rational<N,D>& r) { return T(N)/T(D); } /// raise @c int to a @c static_rational power template<long N,long D> struct power_typeof_helper<int,static_rational<N,D> > { typedef double type; static type value(const int& x) { const static_rational<N,D> rat; return std::pow(double(x),double(rat.numerator())/double(rat.denominator())); } }; /// raise @c float to a @c static_rational power template<long N,long D> struct power_typeof_helper<float,static_rational<N,D> > { typedef double type; static type value(const float& x) { const static_rational<N,D> rat; return std::pow(x,float(rat.numerator())/float(rat.denominator())); } }; /// raise @c double to a @c static_rational power template<long N,long D> struct power_typeof_helper<double,static_rational<N,D> > { typedef double type; static type value(const double& x) { const static_rational<N,D> rat; return std::pow(x,double(rat.numerator())/double(rat.denominator())); } }; /// raise @c std::complex<float> to a @c static_rational power template<long N,long D> struct power_typeof_helper<std::complex<float>,static_rational<N,D> > { typedef std::complex<float> type; static type value(const std::complex<float>& x) { const static_rational<N,D> rat; return std::pow(x,std::complex<float>(rat.numerator())/std::complex<float>(rat.denominator())); } }; /// raise @c std::complex<double> to a @c static_rational power template<long N,long D> struct power_typeof_helper<std::complex<double>,static_rational<N,D> > { typedef std::complex<double> type; static type value(const std::complex<double>& x) { const static_rational<N,D> rat; return std::pow(x,std::complex<double>(rat.numerator())/std::complex<double>(rat.denominator())); } }; /// take @c static_rational root of an @c int template<long N,long D> struct root_typeof_helper<int,static_rational<N,D> > { typedef double type; static type value(const int& x) { const static_rational<N,D> rat; return std::pow(double(x),double(rat.denominator())/double(rat.numerator())); } }; /// take @c static_rational root of a @c float template<long N,long D> struct root_typeof_helper<float,static_rational<N,D> > { typedef float type; static type value(const float& x) { const static_rational<N,D> rat; return std::pow(x,float(rat.denominator())/float(rat.numerator())); } }; /// take @c static_rational root of a @c double template<long N,long D> struct root_typeof_helper<double,static_rational<N,D> > { typedef double type; static type value(const double& x) { const static_rational<N,D> rat; return std::pow(x,double(rat.denominator())/double(rat.numerator())); } }; /// take @c static_rational root of a @c std::complex<float> template<long N,long D> struct root_typeof_helper<std::complex<float>,static_rational<N,D> > { typedef std::complex<float> type; static type value(const std::complex<float>& x) { const static_rational<N,D> rat; return std::pow(x,std::complex<float>(rat.denominator())/std::complex<float>(rat.numerator())); } }; /// take @c static_rational root of a @c std::complex<double> template<long N,long D> struct root_typeof_helper<std::complex<double>,static_rational<N,D> > { typedef std::complex<double> type; static type value(const std::complex<double>& x) { const static_rational<N,D> rat; return std::pow(x,std::complex<double>(rat.denominator())/std::complex<double>(rat.numerator())); } }; // need powers and roots of char, short, long long, unsigned integers... /// raise a value to a @c static_rational power template<class Rat,class Y> typename power_typeof_helper<Y,Rat>::type pow(const Y& x) { return power_typeof_helper<Y,Rat>::value(x); } /// raise a value to an integer power template<long N,class Y> typename power_typeof_helper<Y,static_rational<N> >::type pow(const Y& x) { return power_typeof_helper<Y,static_rational<N> >::value(x); } /// take the @c static_rational root of a value template<class Rat,class Y> typename root_typeof_helper<Y,Rat>::type root(const Y& x) { return root_typeof_helper<Y,Rat>::value(x); } /// take the integer root of a value template<long N,class Y> typename root_typeof_helper<Y,static_rational<N> >::type root(const Y& x) { return root_typeof_helper<Y,static_rational<N> >::value(x); } namespace mpl { 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< T0::Numerator*T1::Denominator+T1::Numerator*T0::Denominator, T0::Denominator*T1::Denominator >::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< T0::Numerator*T1::Denominator-T1::Numerator*T0::Denominator, T0::Denominator*T1::Denominator >::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< T0::Numerator*T1::Numerator, T0::Denominator*T1::Denominator >::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< T0::Numerator*T1::Denominator, T0::Denominator*T1::Numerator >::type type; }; }; template<> struct negate_impl<boost::units::detail::static_rational_tag> { template<class T0> struct apply { typedef typename boost::units::static_rational<-T0::Numerator,T0::Denominator>::type type; }; }; } // namespace mpl } // namespace boost #endif // BOOST_STATIC_RATIONAL_HPP |
From: Matthias S. <mat...@us...> - 2007-04-13 19:41:21
|
Update of /cvsroot/boost-sandbox/boost-sandbox/boost/units/detail In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv4639/boost/units/detail Modified Files: io_impl.hpp Log Message: removed parentheses in output of negative exponents Index: io_impl.hpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/boost/units/detail/io_impl.hpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- io_impl.hpp 29 Mar 2007 00:32:06 -0000 1.2 +++ io_impl.hpp 13 Apr 2007 19:41:09 -0000 1.3 @@ -45,7 +45,8 @@ template<class Char, class Traits, integer_type N> static void apply(std::basic_ostream<Char, Traits>& os,const static_rational<N>&) { - os << '(' << N << ')'; +// os << '(' << N << ')'; + os << N; } }; |
From: Matthias S. <mat...@us...> - 2007-04-13 06:09:57
|
Update of /cvsroot/boost-sandbox/boost-sandbox/libs/units/example In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv11791/libs/units/example Modified Files: test_system.hpp unit_example_21.cpp Log Message: changes to use granular headers Index: unit_example_21.cpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/libs/units/example/unit_example_21.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- unit_example_21.cpp 29 Mar 2007 19:41:23 -0000 1.2 +++ unit_example_21.cpp 13 Apr 2007 06:09:44 -0000 1.3 @@ -29,6 +29,7 @@ #include <boost/units/io.hpp> #include <boost/units/conversion.hpp> +#include <boost/units/ordinal.hpp> #include <boost/units/unit.hpp> #include <boost/units/quantity.hpp> #include <boost/units/systems/physical_units.hpp> Index: test_system.hpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/libs/units/example/test_system.hpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- test_system.hpp 11 Apr 2007 21:24:04 -0000 1.5 +++ test_system.hpp 13 Apr 2007 06:09:44 -0000 1.6 @@ -13,7 +13,10 @@ #include <boost/mpl/list.hpp> #include <boost/mpl/vector.hpp> +#include <boost/units/base_dimension.hpp> +#include <boost/units/derived_dimension.hpp> #include <boost/units/io.hpp> +#include <boost/units/ordinal.hpp> #include <boost/units/quantity.hpp> #include <boost/units/static_constant.hpp> #include <boost/units/unit.hpp> |
Update of /cvsroot/boost-sandbox/boost-sandbox/boost/units In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv11338/boost/units Modified Files: base_dimension.hpp derived_dimension.hpp dim.hpp dimension.hpp dimensionless_type.hpp static_rational.hpp units_fwd.hpp Log Message: changes to use granular headers Index: dimension.hpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/boost/units/dimension.hpp,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- dimension.hpp 13 Apr 2007 03:46:35 -0000 1.8 +++ dimension.hpp 13 Apr 2007 06:08:52 -0000 1.9 @@ -19,9 +19,11 @@ #include <boost/mpl/bool_fwd.hpp> #include <boost/mpl/is_sequence.hpp> #include <boost/mpl/list.hpp> +#include <boost/mpl/long.hpp> #include <boost/mpl/size.hpp> #include <boost/units/dim.hpp> +#include <boost/units/dimensionless_type.hpp> #include <boost/units/operators.hpp> #include <boost/units/static_rational.hpp> #include <boost/units/detail/dimension_impl.hpp> @@ -32,14 +34,14 @@ namespace boost { namespace units { - -/// Dimension lists in which all exponents resolve to zero reduce to @c dimensionless_type. -struct dimensionless_type -{ - typedef dimensionless_type type; - typedef detail::dimension_list_tag tag; - typedef mpl::long_<0> size; -}; +// +///// Dimension lists in which all exponents resolve to zero reduce to @c dimensionless_type. +//struct dimensionless_type +//{ +// typedef dimensionless_type type; +// typedef detail::dimension_list_tag tag; +// typedef mpl::long_<0> size; +//}; /// Reduce dimension list to cardinal form. This algorithm collapses duplicate unit /// tags, strips dimensionless tags, and sorts the resulting list. Sorting of homogeneous @@ -56,22 +58,22 @@ typedef typename detail::sort_dims_to_mpl_list<type2>::type type; }; - -/// Check that a type is a valid dimension list. -template<typename Seq> -struct is_dimension_list : - public mpl::false_ -{ }; - -template<typename Item, typename Next> -struct is_dimension_list<dimension_list<Item, Next> > : - public mpl::true_ -{ }; - -template<> -struct is_dimension_list<dimensionless_type> : - public mpl::true_ -{ }; +// +///// Check that a type is a valid dimension list. +//template<typename Seq> +//struct is_dimension_list : +// public mpl::false_ +//{ }; +// +//template<typename Item, typename Next> +//struct is_dimension_list<dimension_list<Item, Next> > : +// public mpl::true_ +//{ }; +// +//template<> +//struct is_dimension_list<dimensionless_type> : +// public mpl::true_ +//{ }; /// Raise a dimension list to a scalar power. template<typename DL,typename Ex> @@ -112,23 +114,23 @@ static_rational<N,D> >::type type; }; - -/// A utility class for defining base dimensions. -template<long N> struct base_dimension; - -/// each specialization must be separately instantiated in boost::units namespace to prevent duplication of tag values -#define BOOST_UNITS_REGISTER_BASE_DIMENSION(name, N) \ -template<> \ -struct base_dimension<N> : \ - public mpl::int_<N> \ -{ \ - typedef base_dimension<N> this_type; \ - typedef mpl::int_<N> value; \ - \ - typedef make_dimension_list< mpl::list< dim< this_type,static_rational<1> > > >::type type; \ -}; \ - \ -typedef base_dimension<N> name \ +// +///// A utility class for defining base dimensions. +//template<long N> struct base_dimension; +// +///// each specialization must be separately instantiated in boost::units namespace to prevent duplication of tag values +//#define BOOST_UNITS_REGISTER_BASE_DIMENSION(name, N) \ +//template<> \ +//struct base_dimension<N> : \ +// public mpl::int_<N> \ +//{ \ +// typedef base_dimension<N> this_type; \ +// typedef mpl::int_<N> value; \ +// \ +// typedef make_dimension_list< mpl::list< dim< this_type,static_rational<1> > > >::type type; \ +//}; \ +// \ +//typedef base_dimension<N> name \ //// gcc doesn't like this for some reason... ///// each specialization must be separately instantiated in boost::units namespace to prevent duplication of tag values @@ -144,28 +146,28 @@ //}; \ // \ //typedef boost::units::base_dimension<N> name \ - -/// A utility class for defining composite dimensions with integer powers. -template<class DT1 = dimensionless_type,int E1 = 0, - class DT2 = dimensionless_type,int E2 = 0, - class DT3 = dimensionless_type,int E3 = 0, - class DT4 = dimensionless_type,int E4 = 0, - class DT5 = dimensionless_type,int E5 = 0, - class DT6 = dimensionless_type,int E6 = 0, - class DT7 = dimensionless_type,int E7 = 0, - class DT8 = dimensionless_type,int E8 = 0> -struct derived_dimension -{ - typedef typename - make_dimension_list< boost::mpl::list< dim< DT1,static_rational<E1> >, - dim< DT2,static_rational<E2> >, - dim< DT3,static_rational<E3> >, - dim< DT4,static_rational<E4> >, - dim< DT5,static_rational<E5> >, - dim< DT6,static_rational<E6> >, - dim< DT7,static_rational<E7> >, - dim< DT8,static_rational<E8> > > >::type type; -}; +// +///// A utility class for defining composite dimensions with integer powers. +//template<class DT1 = dimensionless_type,int E1 = 0, +// class DT2 = dimensionless_type,int E2 = 0, +// class DT3 = dimensionless_type,int E3 = 0, +// class DT4 = dimensionless_type,int E4 = 0, +// class DT5 = dimensionless_type,int E5 = 0, +// class DT6 = dimensionless_type,int E6 = 0, +// class DT7 = dimensionless_type,int E7 = 0, +// class DT8 = dimensionless_type,int E8 = 0> +//struct derived_dimension +//{ +// typedef typename +// make_dimension_list< mpl::list< dim< DT1,static_rational<E1> >, +// dim< DT2,static_rational<E2> >, +// dim< DT3,static_rational<E3> >, +// dim< DT4,static_rational<E4> >, +// dim< DT5,static_rational<E5> >, +// dim< DT6,static_rational<E6> >, +// dim< DT7,static_rational<E7> >, +// dim< DT8,static_rational<E8> > > >::type type; +//}; } // namespace units Index: units_fwd.hpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/boost/units/units_fwd.hpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- units_fwd.hpp 13 Apr 2007 04:56:14 -0000 1.2 +++ units_fwd.hpp 13 Apr 2007 06:08:52 -0000 1.3 @@ -18,9 +18,12 @@ template<long N> struct ordinal; template<typename T,typename V> struct dim; - template<typename T> struct is_dim; +struct dimensionless_type; +template<class Item,class Next> struct dimension_list; +template<typename Seq> struct make_dimension_list; + template<class T> struct is_dimensionless; template<class S1,class S2> struct is_implicitly_convertible; template<class T> struct get_dimension; Index: derived_dimension.hpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/boost/units/derived_dimension.hpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- derived_dimension.hpp 13 Apr 2007 05:36:03 -0000 1.1 +++ derived_dimension.hpp 13 Apr 2007 06:08:52 -0000 1.2 @@ -11,10 +11,8 @@ #ifndef BOOST_UNITS_DERIVED_DIMENSION_HPP #define BOOST_UNITS_DERIVED_DIMENSION_HPP -//#include <boost/mpl/int.hpp> #include <boost/mpl/list.hpp> -//#include <boost/units/dimensionless_type.hpp> #include <boost/units/static_rational.hpp> #include <boost/units/units_fwd.hpp> Index: base_dimension.hpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/boost/units/base_dimension.hpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- base_dimension.hpp 13 Apr 2007 05:17:06 -0000 1.1 +++ base_dimension.hpp 13 Apr 2007 06:08:52 -0000 1.2 @@ -14,6 +14,7 @@ #include <boost/mpl/int.hpp> #include <boost/mpl/list.hpp> +#include <boost/units/config.hpp> #include <boost/units/static_rational.hpp> #include <boost/units/units_fwd.hpp> @@ -42,6 +43,14 @@ } // namespace boost +#if BOOST_UNITS_HAS_BOOST_TYPEOF + +#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP() + +BOOST_TYPEOF_REGISTER_TEMPLATE(boost::units::base_dimension, 1) + +#endif + // doesn't work with g++ for some reason //namespace boost { // Index: dim.hpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/boost/units/dim.hpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- dim.hpp 13 Apr 2007 01:05:28 -0000 1.3 +++ dim.hpp 13 Apr 2007 06:08:52 -0000 1.4 @@ -14,47 +14,87 @@ #include <boost/mpl/bool_fwd.hpp> #include <boost/mpl/int.hpp> +#include <boost/units/config.hpp> +#include <boost/units/is_dim.hpp> #include <boost/units/static_rational.hpp> #include <boost/units/detail/dim_impl.hpp> /// \file /// \brief Handling of fundamental dimension/exponent pairs. +//namespace boost { +// +//namespace units { +// +///// Class for defining a cardinal ordering of tags to faciliate compile-time sorting. +//template<long N> struct ordinal { typedef typename boost::mpl::int_<N> value; }; +// +//} +// +//} +// +//#if BOOST_UNITS_HAS_BOOST_TYPEOF +// +//#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP() +// +//BOOST_TYPEOF_REGISTER_TEMPLATE(boost::units::ordinal, (long)) +// +//#endif + namespace boost { namespace units { -/// Class for defining a cardinal ordering of tags to faciliate compile-time sorting. -template<long N> struct ordinal { typedef typename boost::mpl::int_<N> value; }; +namespace detail { -} +struct dim_tag { }; } -#if BOOST_UNITS_HAS_BOOST_TYPEOF +/// \brief Dimension tag/exponent pair for a single fundamental dimension. +/// +/// \detailed +/// The dim class represents a single dimension tag/dimension exponent pair. +/// That is, @c dim<tag_type,value_type> is a pair where @c tag_type represents the +/// fundamental dimension being represented and @c value_type represents the +/// exponent of that fundamental dimension as a @c static_rational or other type +/// providing the required compile-time arithmetic operations. @c tag_type must +/// provide an ordinal value to allow sorting of lists of dims at compile-time. +/// This can be easily accomplished by inheriting from @c ordinal<N>. Otherwise, +/// @c tag_type may be any type. +template<typename T,typename V> +struct dim +{ + typedef dim type; + typedef detail::dim_tag tag; + typedef T tag_type; + typedef V value_type; +}; -#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP() +///// Check that a type is a valid @c dim. +//template<typename T> +//struct is_dim : +// public mpl::false_ +//{ }; +// +//template<typename T,typename V> +//struct is_dim< dim<T,V> > : +// public mpl::true_ +//{ }; -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::units::ordinal, (long)) +} // namespace units -#endif +} // namespace boost -namespace boost { +#if BOOST_UNITS_HAS_BOOST_TYPEOF -namespace units { +#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP() -/// Check that a type is a valid @c dim. -template<typename T> -struct is_dim : - public mpl::false_ -{ }; +BOOST_TYPEOF_REGISTER_TEMPLATE(boost::units::dim, 2) -template<typename T,typename V> -struct is_dim< dim<T,V> > : - public mpl::true_ -{ }; +#endif -} // namespace units +namespace boost { namespace mpl { Index: static_rational.hpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/boost/units/static_rational.hpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- static_rational.hpp 13 Apr 2007 01:05:28 -0000 1.6 +++ static_rational.hpp 13 Apr 2007 06:08:52 -0000 1.7 @@ -73,8 +73,10 @@ static const integer_type den = static_cast<integer_type>(boost::math::static_gcd<nabs,dabs>::value); - public: + public: + // for mpl arithmetic support typedef detail::static_rational_tag tag; + static const integer_type Numerator = N/den, Denominator = D/den; Index: dimensionless_type.hpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/boost/units/dimensionless_type.hpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- dimensionless_type.hpp 13 Apr 2007 05:28:24 -0000 1.1 +++ dimensionless_type.hpp 13 Apr 2007 06:08:52 -0000 1.2 @@ -13,7 +13,8 @@ #include <boost/mpl/long.hpp> -#include <boost/units/detail/dimension_impl.hpp> +#include <boost/units/config.hpp> +#include <boost/units/dimension_list.hpp> namespace boost { @@ -31,4 +32,12 @@ } // namespace boost +#if BOOST_UNITS_HAS_BOOST_TYPEOF + +#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP() + +BOOST_TYPEOF_REGISTER_TYPE(boost::units::dimensionless_type) + +#endif + #endif // BOOST_UNITS_DIMENSIONLESS_TYPE_HPP \ No newline at end of file |
From: Matthias S. <mat...@us...> - 2007-04-13 06:08:53
|
Update of /cvsroot/boost-sandbox/boost-sandbox/boost/units/detail In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv11338/boost/units/detail Modified Files: dim_impl.hpp dimension_impl.hpp Log Message: changes to use granular headers Index: dimension_impl.hpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/boost/units/detail/dimension_impl.hpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- dimension_impl.hpp 12 Apr 2007 00:39:12 -0000 1.2 +++ dimension_impl.hpp 13 Apr 2007 06:08:52 -0000 1.3 @@ -19,63 +19,66 @@ #include <boost/mpl/push_front.hpp> #include <boost/mpl/size.hpp> +#include <boost/units/config.hpp> +#include <boost/units/dimension_list.hpp> #include <boost/units/static_rational.hpp> +#include <boost/units/units_fwd.hpp> /// \file /// \brief Core class and metaprogramming utilities for compile-time dimensional analysis. /// /// \detailed -namespace boost { - -namespace units { - -struct dimensionless_type; - -} - -} - -#if BOOST_UNITS_HAS_BOOST_TYPEOF - -#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP() - -BOOST_TYPEOF_REGISTER_TYPE(boost::units::dimensionless_type) - -#endif - -namespace boost { - -namespace units { - -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; -}; - -} - -} - -#if BOOST_UNITS_HAS_BOOST_TYPEOF - -#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP() - -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::units::dimension_list, 2) - -#endif +//namespace boost { +// +//namespace units { +// +//struct dimensionless_type; +// +//} +// +//} +// +//#if BOOST_UNITS_HAS_BOOST_TYPEOF +// +//#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP() +// +//BOOST_TYPEOF_REGISTER_TYPE(boost::units::dimensionless_type) +// +//#endif +//namespace boost { +// +//namespace units { +// +//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; +//}; +// +//} +// +//} +// +//#if BOOST_UNITS_HAS_BOOST_TYPEOF +// +//#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP() +// +//BOOST_TYPEOF_REGISTER_TEMPLATE(boost::units::dimension_list, 2) +// +//#endif +// namespace boost { namespace units { Index: dim_impl.hpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/boost/units/detail/dim_impl.hpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- dim_impl.hpp 13 Apr 2007 04:56:14 -0000 1.3 +++ dim_impl.hpp 13 Apr 2007 06:08:52 -0000 1.4 @@ -14,52 +14,52 @@ #include <boost/mpl/bool_fwd.hpp> #include <boost/mpl/less.hpp> -#include <boost/units/static_rational.hpp> +#include <boost/units/units_fwd.hpp> /// \file /// \brief Class encapsulating a dimension tag/value pair -namespace boost { - -namespace units { - -namespace detail { - -struct dim_tag { }; - -} - -/// \brief Dimension tag/exponent pair for a single fundamental dimension. -/// -/// \detailed -/// The dim class represents a single dimension tag/dimension exponent pair. -/// That is, @c dim<tag_type,value_type> is a pair where @c tag_type represents the -/// fundamental dimension being represented and @c value_type represents the -/// exponent of that fundamental dimension as a @c static_rational or other type -/// providing the required compile-time arithmetic operations. @c tag_type must -/// provide an ordinal value to allow sorting of lists of dims at compile-time. -/// This can be easily accomplished by inheriting from @c ordinal<N>. Otherwise, -/// @c tag_type may be any type. -template<typename T,typename V> -struct dim -{ - typedef dim type; - typedef detail::dim_tag tag; - typedef T tag_type; - typedef V value_type; -}; - -} - -} - -#if BOOST_UNITS_HAS_BOOST_TYPEOF - -#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP() - -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::units::dim, 2) - -#endif +//namespace boost { +// +//namespace units { +// +//namespace detail { +// +//struct dim_tag { }; +// +//} // namespace detail +// +///// \brief Dimension tag/exponent pair for a single fundamental dimension. +///// +///// \detailed +///// The dim class represents a single dimension tag/dimension exponent pair. +///// That is, @c dim<tag_type,value_type> is a pair where @c tag_type represents the +///// fundamental dimension being represented and @c value_type represents the +///// exponent of that fundamental dimension as a @c static_rational or other type +///// providing the required compile-time arithmetic operations. @c tag_type must +///// provide an ordinal value to allow sorting of lists of dims at compile-time. +///// This can be easily accomplished by inheriting from @c ordinal<N>. Otherwise, +///// @c tag_type may be any type. +//template<typename T,typename V> +//struct dim +//{ +// typedef dim type; +// typedef detail::dim_tag tag; +// typedef T tag_type; +// typedef V value_type; +//}; +// +//} // namespace units +// +//} // namespace boost +// +//#if BOOST_UNITS_HAS_BOOST_TYPEOF +// +//#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP() +// +//BOOST_TYPEOF_REGISTER_TEMPLATE(boost::units::dim, 2) +// +//#endif namespace boost { |
From: Matthias S. <mat...@us...> - 2007-04-13 06:08:53
|
Update of /cvsroot/boost-sandbox/boost-sandbox/boost/units/systems/si In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv11338/boost/units/systems/si Modified Files: base.hpp Log Message: changes to use granular headers Index: base.hpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/boost/units/systems/si/base.hpp,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- base.hpp 10 Apr 2007 22:58:42 -0000 1.7 +++ base.hpp 13 Apr 2007 06:08:52 -0000 1.8 @@ -14,6 +14,7 @@ #include <string> #include <boost/units/io.hpp> +#include <boost/units/ordinal.hpp> #include <boost/units/static_constant.hpp> #include <boost/units/unit.hpp> #include <boost/units/system.hpp> |
From: Matthias S. <mat...@us...> - 2007-04-13 06:08:52
|
Update of /cvsroot/boost-sandbox/boost-sandbox/boost/units/systems In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv11338/boost/units/systems Modified Files: abstract.hpp physical_units.hpp Log Message: changes to use granular headers Index: abstract.hpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/boost/units/systems/abstract.hpp,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- abstract.hpp 10 Apr 2007 22:58:42 -0000 1.7 +++ abstract.hpp 13 Apr 2007 06:08:52 -0000 1.8 @@ -14,6 +14,7 @@ #include <string> #include <boost/units/conversion.hpp> +#include <boost/units/ordinal.hpp> #include <boost/units/system.hpp> #include <boost/units/systems/physical_units.hpp> Index: physical_units.hpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/boost/units/systems/physical_units.hpp,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- physical_units.hpp 13 Apr 2007 03:46:35 -0000 1.16 +++ physical_units.hpp 13 Apr 2007 06:08:52 -0000 1.17 @@ -11,6 +11,8 @@ #ifndef BOOST_UNITS_PHYSICAL_UNITS_HPP #define BOOST_UNITS_PHYSICAL_UNITS_HPP +#include <boost/units/base_dimension.hpp> +#include <boost/units/derived_dimension.hpp> #include <boost/units/static_constant.hpp> #include <boost/units/system.hpp> #include <boost/units/unit.hpp> @@ -38,9 +40,9 @@ BOOST_UNITS_REGISTER_BASE_DIMENSION(plane_angle_dim,-2); ///> base dimension of plane angle BOOST_UNITS_REGISTER_BASE_DIMENSION(solid_angle_dim,-1); ///> base dimension of solid angle -} +} // namespace units -} +} // namespace boost #if BOOST_UNITS_HAS_BOOST_TYPEOF |
From: Matthias S. <mat...@us...> - 2007-04-13 06:08:52
|
Update of /cvsroot/boost-sandbox/boost-sandbox/boost/units/systems/cgs In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv11338/boost/units/systems/cgs Modified Files: base.hpp Log Message: changes to use granular headers Index: base.hpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/boost/units/systems/cgs/base.hpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- base.hpp 10 Apr 2007 22:58:42 -0000 1.5 +++ base.hpp 13 Apr 2007 06:08:52 -0000 1.6 @@ -14,6 +14,7 @@ #include <string> #include <boost/units/io.hpp> +#include <boost/units/ordinal.hpp> #include <boost/units/static_constant.hpp> #include <boost/units/unit.hpp> #include <boost/units/system.hpp> |
From: Matthias S. <mat...@us...> - 2007-04-13 06:08:09
|
Update of /cvsroot/boost-sandbox/boost-sandbox/boost/units In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv10934/boost/units Added Files: ordinal.hpp Log Message: granular ordinal header --- NEW FILE: ordinal.hpp --- // 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_ORDINAL_HPP #define BOOST_UNITS_ORDINAL_HPP #include <boost/mpl/long.hpp> #include <boost/units/config.hpp> namespace boost { namespace units { /// Class for defining a cardinal ordering of tags to faciliate compile-time sorting. template<long N> struct ordinal { typedef typename boost::mpl::long_<N> value; }; } // namespace units } // namespace boost #if BOOST_UNITS_HAS_BOOST_TYPEOF #include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP() BOOST_TYPEOF_REGISTER_TEMPLATE(boost::units::ordinal, (long)) #endif #endif // BOOST_UNITS_ORDINAL_HPP |
From: Matthias S. <mat...@us...> - 2007-04-13 06:06:47
|
Update of /cvsroot/boost-sandbox/boost-sandbox/boost/units In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv10517/boost/units Added Files: is_dimension_list.hpp Log Message: granular is_dimension_list predicate --- NEW FILE: is_dimension_list.hpp --- // 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_IS_DIMENSION_LIST_HPP #define BOOST_UNITS_IS_DIMENSION_LIST_HPP #include <boost/mpl/bool.hpp> #include <boost/units/units_fwd.hpp> namespace boost { namespace units { /// Check that a type is a valid dimension list. template<typename Seq> struct is_dimension_list : public mpl::false_ { }; template<typename Item, typename Next> struct is_dimension_list<dimension_list<Item, Next> > : public mpl::true_ { }; template<> struct is_dimension_list<dimensionless_type> : public mpl::true_ { }; } // namespace units } // namespace boost #endif // BOOST_UNITS_IS_DIMENSION_LIST_HPP |
From: Matthias S. <mat...@us...> - 2007-04-13 06:06:11
|
Update of /cvsroot/boost-sandbox/boost-sandbox/boost/units In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv10131/boost/units Added Files: is_dim.hpp Log Message: granular is_dim predicate --- NEW FILE: is_dim.hpp --- // 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_IS_DIM_HPP #define BOOST_UNITS_IS_DIM_HPP #include <boost/mpl/bool.hpp> #include <boost/units/units_fwd.hpp> namespace boost { namespace units { /// Check that a type is a valid @c dim. template<typename T> struct is_dim : public mpl::false_ { }; template<typename T,typename V> struct is_dim< dim<T,V> > : public mpl::true_ { }; } // namespace units } // namespace boost #endif // BOOST_UNITS_IS_DIM_HPP |