|
From: Matthias S. <mat...@us...> - 2007-03-29 16:51:51
|
Update of /cvsroot/boost-sandbox/boost-sandbox/boost/units In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv4845 Modified Files: quantity.hpp Log Message: changed quantity_reinterpret_cast to remove need to be friend of quantity Index: quantity.hpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/boost/units/quantity.hpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- quantity.hpp 29 Mar 2007 00:29:12 -0000 1.2 +++ quantity.hpp 29 Mar 2007 16:51:51 -0000 1.3 @@ -26,13 +26,7 @@ template<class Q1,class Q2> class conversion_helper; template<class Unit,class Y = double> class quantity; - -template<class T, class Quantity> -T quantity_reinterpret_cast(const Quantity& q); - -template<class T, class Quantity> -T quantity_reinterpret_cast(Quantity& q); - + /// class declaration //template<class System,class Dim,class Y> //class quantity<unit<Dim,System>,Y> @@ -42,9 +36,6 @@ template<class Unit,class Y> class quantity { - friend const Y& quantity_reinterpret_cast(const quantity& q); - friend Y& quantity_reinterpret_cast<>(quantity& q); - friend const Y& quantity_reinterpret_cast<>(quantity& q); public: typedef quantity<Unit,Y> this_type; typedef typename get_dimension<Unit>::type Dim; @@ -170,9 +161,6 @@ template<class System,class Y> class quantity<unit<dimensionless_type,System>,Y> { - friend const Y& quantity_reinterpret_cast(const quantity& q); - friend Y& quantity_reinterpret_cast<>(quantity& q); - friend const Y& quantity_reinterpret_cast<>(quantity& q); public: typedef quantity<unit<dimensionless_type,System>,Y> this_type; @@ -273,17 +261,16 @@ namespace units { /// extract a reference to the value type -template<class T, class Quantity> -T quantity_reinterpret_cast(const Quantity& q) +template<class X, class Unit,class Y> +X quantity_reinterpret_cast(const quantity<Unit,Y>& q) { - return(q.val_); + return reinterpret_cast<X>(const_cast<Y&>(q.value())); } -/// extract a (mutable) reference to the value type -template<class T, class Quantity> -T quantity_reinterpret_cast(Quantity& q) +template<class X, class Unit,class Y> +X quantity_reinterpret_cast(quantity<Unit,Y>& q) { - return(q.val_); + return reinterpret_cast<X>(const_cast<Y&>(q.value())); } /// swap quantities |