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 |