|
From: Matthias S. <mat...@us...> - 2007-04-13 05:09:15
|
Update of /cvsroot/boost-sandbox/boost-sandbox/boost/units In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv13206/boost/units Modified Files: quantity.hpp unit.hpp units_fwd.hpp Log Message: forward declarations and granular metafunctions/predicates added Index: units_fwd.hpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/boost/units/units_fwd.hpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- units_fwd.hpp 13 Apr 2007 04:28:38 -0000 1.1 +++ units_fwd.hpp 13 Apr 2007 04:56:14 -0000 1.2 @@ -21,13 +21,13 @@ template<typename T> struct is_dim; -template<class Dim,class System> class unit; - template<class T> struct is_dimensionless; template<class S1,class S2> struct is_implicitly_convertible; template<class T> struct get_dimension; template<class T> struct get_system; +template<class Dim,class System> class unit; + template<class SystemTag,class DimensionTag> struct unit_info; template<class System> struct dimensionless_unit; template<class T> struct is_unit; Index: unit.hpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/boost/units/unit.hpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- unit.hpp 12 Apr 2007 00:39:12 -0000 1.2 +++ unit.hpp 13 Apr 2007 04:56:14 -0000 1.3 @@ -15,6 +15,7 @@ #include <boost/units/dimension.hpp> #include <boost/units/system.hpp> +#include <boost/units/units_fwd.hpp> #include <boost/units/detail/unit_impl.hpp> namespace boost { @@ -27,7 +28,6 @@ template<class Dim,class System> class unit { - BOOST_STATIC_ASSERT((detail::check_system<System, Dim>::value == true)); public: typedef unit<Dim,System> this_type; typedef Dim dimension_type; @@ -38,6 +38,9 @@ //~unit() { } this_type& operator=(const this_type&) { } + + private: + BOOST_STATIC_ASSERT((detail::check_system<System, Dim>::value == true)); }; } @@ -56,69 +59,67 @@ namespace units { -/// utility class to simplify construction of dimensionless units in a system -template<class System> -struct dimensionless_unit -{ - typedef unit<dimensionless_type,System> type; -}; - /// class to specialize for IO -template<class SystemTag,class DimensionTag> struct unit_info; - -template<class T> -struct is_unit : - public mpl::false_ -{ }; - -/// check that a type is a unit -template<class Dim,class System> -struct is_unit< unit<Dim,System> > : - public mpl::true_ -{ }; - -template<class T,class System> -struct is_unit_of_system : - public mpl::false_ -{ }; - -/// check that a type is a unit in a specified system -template<class Dim,class System> -struct is_unit_of_system< unit<Dim,System>,System > : - public mpl::true_ -{ }; - -template<class T,class Dim> -struct is_unit_of_dimension : - public mpl::false_ -{ }; - -/// check that a type is a unit of the specified dimension -template<class Dim,class System> -struct is_unit_of_dimension< unit<Dim,System>,Dim > : - public mpl::true_ -{ }; - -template<class T> -struct is_dimensionless : - public mpl::false_ -{ }; - -/// check if a unit is dimensionless -template<class System> -struct is_dimensionless< unit<dimensionless_type,System> > : - public mpl::true_ -{ }; +//template<class SystemTag,class DimensionTag> struct unit_info; +// +///// utility class to simplify construction of dimensionless units in a system +//template<class System> +//struct dimensionless_unit +//{ +// typedef unit<dimensionless_type,System> type; +//}; +// +//template<class T> +//struct is_unit : +// public mpl::false_ +//{ }; +// +///// check that a type is a unit +//template<class Dim,class System> +//struct is_unit< unit<Dim,System> > : +// public mpl::true_ +//{ }; +// +//template<class T,class System> +//struct is_unit_of_system : +// public mpl::false_ +//{ }; +// +//template<class T,class Dim> +//struct is_unit_of_dimension : +// public mpl::false_ +//{ }; +// +///// check that a type is a unit of the specified dimension +//template<class Dim,class System> +//struct is_unit_of_dimension< unit<Dim,System>,Dim > : +// public mpl::true_ +//{ }; +// +///// check that a type is a dimensionless unit +//template<class T> +//struct is_dimensionless_unit : +// public is_unit_of_dimension<T,dimensionless_type> +//{ }; +// +///// check that a type is a unit in a specified system +//template<class Dim,class System> +//struct is_unit_of_system< unit<Dim,System>,System > : +// public mpl::true_ +//{ }; -/// check that a type is a dimensionless unit -template<class T> -struct is_dimensionless_unit : - public is_unit_of_dimension<T,dimensionless_type> -{ }; - -template<class T> struct get_dimension; +//template<class T> +//struct is_dimensionless : +// public mpl::false_ +//{ }; +// +///// check if a unit is dimensionless +//template<class System> +//struct is_dimensionless< unit<dimensionless_type,System> > : +// public mpl::true_ +//{ }; -template<class S1,class S2> struct is_implicitly_convertible; +//template<class S1,class S2> struct is_implicitly_convertible; template<class S1,class S2> struct is_implicitly_convertible : @@ -184,21 +185,23 @@ typedef heterogeneous_system<S2> system2_type; }; -/// get the dimension of a unit -template<class Dim,class System> -struct get_dimension< unit<Dim,System> > -{ - typedef Dim type; -}; - -template<class T> struct get_system; +//template<class T> struct get_dimension; +// +///// get the dimension of a unit +//template<class Dim,class System> +//struct get_dimension< unit<Dim,System> > +//{ +// typedef Dim type; +//}; -/// get the system of a unit -template<class Dim,class System> -struct get_system< unit<Dim,System> > -{ - typedef System type; -}; +//template<class T> struct get_system; +// +///// get the system of a unit +//template<class Dim,class System> +//struct get_system< unit<Dim,System> > +//{ +// typedef System type; +//}; /// unit unary plus typeof helper template<class Dim,class System> Index: quantity.hpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/boost/units/quantity.hpp,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- quantity.hpp 13 Apr 2007 03:46:13 -0000 1.21 +++ quantity.hpp 13 Apr 2007 04:56:14 -0000 1.22 @@ -18,7 +18,11 @@ #include <boost/utility/enable_if.hpp> #include <boost/type_traits/is_convertible.hpp> +#include <boost/units/dimensionless_quantity.hpp> +#include <boost/units/get_dimension.hpp> +#include <boost/units/get_system.hpp> #include <boost/units/unit.hpp> +#include <boost/units/units_fwd.hpp> namespace boost { @@ -282,6 +286,8 @@ namespace units { +namespace detail { + /// helper class for quantity_cast template<class X,class Y> struct quantity_cast_helper; @@ -303,23 +309,25 @@ type operator()(const quantity<Unit,X>& source) { return source.value(); } }; +} // namespace detail + /// quantity_cast provides mutating access to underlying quantity value_type template<class X,class Y> inline -typename quantity_cast_helper<X,Y>::type +typename detail::quantity_cast_helper<X,Y>::type quantity_cast(Y& source) { - quantity_cast_helper<X,Y> qch; + detail::quantity_cast_helper<X,Y> qch; return qch(source); } template<class X,class Y> inline -typename quantity_cast_helper<X,const Y>::type +typename detail::quantity_cast_helper<X,const Y>::type quantity_cast(const Y& source) { - quantity_cast_helper<X,const Y> qch; + detail::quantity_cast_helper<X,const Y> qch; return qch(source); } @@ -331,75 +339,75 @@ using std::swap; swap(quantity_cast<Y&>(lhs),quantity_cast<Y&>(rhs)); } - -/// utility class to simplify construction of dimensionless quantities -template<class System,class Y> -struct dimensionless_quantity -{ - typedef quantity<typename dimensionless_unit<System>::type,Y> type; -}; - -/// check that a type is a quantity -template<typename T> -struct is_quantity : - public mpl::false_ -{ }; - -template<class Unit, - class Y> -struct is_quantity< quantity<Unit,Y> > : - public mpl::true_ -{ }; - -/// check that a type is a quantity in a specified system -template<class T,class System> -struct is_quantity_of_system : - public mpl::false_ -{ }; - -template<class Dim, - class System, - class Y> -struct is_quantity_of_system< quantity< unit<Dim,System>,Y>,System > : - public mpl::true_ -{ }; - -/// check that a type is a quantity of the specified dimension -template<class T,class Dim> -struct is_quantity_of_dimension : - public mpl::false_ -{ }; - -template<class Dim,class System,class Y> -struct is_quantity_of_dimension< quantity< unit<Dim,System>,Y>,Dim > : - public mpl::true_ -{ }; - -/// check that a type is dimensionless -template<class System,class Y> -struct is_dimensionless< quantity<unit<dimensionless_type,System>,Y> > : - public mpl::true_ -{ }; - -/// check that a type is a dimensionless quantity -template<class T> -struct is_dimensionless_quantity : - public is_quantity_of_dimension<T,dimensionless_type> -{ }; - -/// get dimension -template<class Unit,class Y> -struct get_dimension< quantity<Unit,Y> > -{ - typedef typename get_dimension<Unit>::type type; -}; - -/// get system -template<class Unit,class Y> -struct get_system< quantity<Unit,Y> > -{ - typedef typename get_system<Unit>::type type; -}; +// +///// utility class to simplify construction of dimensionless quantities +//template<class System,class Y> +//struct dimensionless_quantity +//{ +// typedef quantity<typename dimensionless_unit<System>::type,Y> type; +//}; +// +///// check that a type is a quantity +//template<typename T> +//struct is_quantity : +// public mpl::false_ +//{ }; +// +//template<class Unit, +// class Y> +//struct is_quantity< quantity<Unit,Y> > : +// public mpl::true_ +//{ }; +// +///// check that a type is a quantity of the specified dimension +//template<class T,class Dim> +//struct is_quantity_of_dimension : +// public mpl::false_ +//{ }; +// +//template<class Dim,class System,class Y> +//struct is_quantity_of_dimension< quantity< unit<Dim,System>,Y>,Dim > : +// public mpl::true_ +//{ }; +// +///// check that a type is a dimensionless quantity +//template<class T> +//struct is_dimensionless_quantity : +// public is_quantity_of_dimension<T,dimensionless_type> +//{ }; +// +///// check that a type is a quantity in a specified system +//template<class T,class System> +//struct is_quantity_of_system : +// public mpl::false_ +//{ }; +// +//template<class Dim, +// class System, +// class Y> +//struct is_quantity_of_system< quantity< unit<Dim,System>,Y>,System > : +// public mpl::true_ +//{ }; +// +///// check that a type is dimensionless +//template<class System,class Y> +//struct is_dimensionless< quantity<unit<dimensionless_type,System>,Y> > : +// public mpl::true_ +//{ }; +// +///// get dimension +//template<class Unit,class Y> +//struct get_dimension< quantity<Unit,Y> > +//{ +// typedef typename get_dimension<Unit>::type type; +//}; +// +///// get system +//template<class Unit,class Y> +//struct get_system< quantity<Unit,Y> > +//{ +// typedef typename get_system<Unit>::type type; +//}; /// specialize unary plus typeof helper template<class Unit,class Y> |