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 |